@cdk8s/awscdk-resolver 0.0.710 → 0.0.712

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.
Files changed (67) hide show
  1. package/.jsii +3 -3
  2. package/lib/resolve.js +1 -1
  3. package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js +1 -1
  4. package/node_modules/@aws-sdk/client-cloudformation/package.json +1 -1
  5. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +1695 -3
  6. package/node_modules/@smithy/core/dist-es/submodules/protocols/ConfigurableSerdeContext.js +6 -0
  7. package/node_modules/@smithy/core/dist-es/submodules/protocols/UnionSerde.js +26 -0
  8. package/node_modules/@smithy/core/dist-es/submodules/protocols/common.js +3 -0
  9. package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +8 -0
  10. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/JsonSettings.js +1 -0
  11. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/SmithyRpcV2JsonProtocol.js +102 -0
  12. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js +20 -0
  13. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v1/JsonSettings.js +1 -0
  14. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js +167 -0
  15. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js +200 -0
  16. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.js +103 -0
  17. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js +20 -0
  18. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js +211 -0
  19. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js +529 -0
  20. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/detectBufferParsing.js +18 -0
  21. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/jsonReplacer.js +46 -0
  22. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/jsonReviver.js +121 -0
  23. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/needsReviver.js +41 -0
  24. package/node_modules/@smithy/core/dist-es/submodules/protocols/json/parseJsonBody.js +104 -0
  25. package/node_modules/@smithy/core/dist-es/submodules/protocols/writeKey.js +3 -0
  26. package/node_modules/@smithy/core/dist-types/submodules/protocols/ConfigurableSerdeContext.d.ts +8 -0
  27. package/node_modules/@smithy/core/dist-types/submodules/protocols/UnionSerde.d.ts +24 -0
  28. package/node_modules/@smithy/core/dist-types/submodules/protocols/common.d.ts +2 -0
  29. package/node_modules/@smithy/core/dist-types/submodules/protocols/index.d.ts +9 -0
  30. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/JsonSettings.d.ts +13 -0
  31. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/SmithyRpcV2JsonProtocol.d.ts +28 -0
  32. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v1/JsonCodec.d.ts +15 -0
  33. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v1/JsonSettings.d.ts +7 -0
  34. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +14 -0
  35. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +29 -0
  36. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +51 -0
  37. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v2/JsonCodec2.d.ts +13 -0
  38. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +30 -0
  39. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +60 -0
  40. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/detectBufferParsing.d.ts +1 -0
  41. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/jsonReplacer.d.ts +21 -0
  42. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/jsonReviver.d.ts +15 -0
  43. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/needsReviver.d.ts +11 -0
  44. package/node_modules/@smithy/core/dist-types/submodules/protocols/json/parseJsonBody.d.ts +38 -0
  45. package/node_modules/@smithy/core/dist-types/submodules/protocols/writeKey.d.ts +4 -0
  46. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/ConfigurableSerdeContext.d.ts +8 -0
  47. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/UnionSerde.d.ts +24 -0
  48. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/common.d.ts +2 -0
  49. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/index.d.ts +9 -0
  50. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/JsonSettings.d.ts +13 -0
  51. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/SmithyRpcV2JsonProtocol.d.ts +28 -0
  52. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonCodec.d.ts +15 -0
  53. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonSettings.d.ts +7 -0
  54. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +14 -0
  55. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +29 -0
  56. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +51 -0
  57. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonCodec2.d.ts +13 -0
  58. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +30 -0
  59. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +60 -0
  60. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/detectBufferParsing.d.ts +1 -0
  61. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/jsonReplacer.d.ts +21 -0
  62. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/jsonReviver.d.ts +15 -0
  63. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/needsReviver.d.ts +11 -0
  64. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +38 -0
  65. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/writeKey.d.ts +4 -0
  66. package/node_modules/@smithy/core/package.json +2 -1
  67. package/package.json +3 -3
@@ -0,0 +1,121 @@
1
+ import { NumericValue } from "@smithy/core/serde";
2
+ export function jsonReviver(key, value, context) {
3
+ if (context?.source) {
4
+ const numericString = context.source;
5
+ if (typeof value === "number") {
6
+ const inSafeRange = value <= Number.MAX_SAFE_INTEGER && value >= Number.MIN_SAFE_INTEGER;
7
+ if (inSafeRange) {
8
+ if (isRepresentable(numericString, value)) {
9
+ return value;
10
+ }
11
+ return new NumericValue(numericString, "bigDecimal");
12
+ }
13
+ else {
14
+ if (isFractionalBigNumeric(numericString)) {
15
+ return new NumericValue(numericString, "bigDecimal");
16
+ }
17
+ if (/[eE]/.test(numericString)) {
18
+ return expandExponentToBigInt(numericString);
19
+ }
20
+ return BigInt(numericString);
21
+ }
22
+ }
23
+ }
24
+ return value;
25
+ }
26
+ function isFractionalBigNumeric(s) {
27
+ const dotIndex = s.indexOf(".");
28
+ if (dotIndex === -1) {
29
+ return false;
30
+ }
31
+ const eIndex = s.search(/[eE]/);
32
+ if (eIndex === -1) {
33
+ return true;
34
+ }
35
+ const fracDigits = eIndex - dotIndex - 1;
36
+ const exp = parseInt(s.slice(eIndex + 1), 10);
37
+ return exp < fracDigits;
38
+ }
39
+ function isRepresentable(numericString, value) {
40
+ if (numericString === String(value)) {
41
+ return true;
42
+ }
43
+ if (Object.is(value, -0)) {
44
+ return true;
45
+ }
46
+ if (/[eE]/.test(numericString)) {
47
+ return expandToDecimal(numericString) === expandToDecimal(String(value));
48
+ }
49
+ const normalized = numericString.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
50
+ const canonical = String(value);
51
+ if (normalized === canonical) {
52
+ return true;
53
+ }
54
+ if (/[eE]/.test(canonical)) {
55
+ return normalized === expandToDecimal(canonical);
56
+ }
57
+ return false;
58
+ }
59
+ function expandToDecimal(s) {
60
+ const negative = s.startsWith("-");
61
+ const abs = negative ? s.slice(1) : s;
62
+ const eIndex = abs.search(/[eE]/);
63
+ let result;
64
+ if (eIndex === -1) {
65
+ result = abs;
66
+ }
67
+ else {
68
+ const exp = parseInt(abs.slice(eIndex + 1), 10);
69
+ const mantissa = abs.slice(0, eIndex);
70
+ const dotIndex = mantissa.indexOf(".");
71
+ let digits;
72
+ let intLen;
73
+ if (dotIndex === -1) {
74
+ digits = mantissa;
75
+ intLen = mantissa.length;
76
+ }
77
+ else {
78
+ digits = mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1);
79
+ intLen = dotIndex;
80
+ }
81
+ digits = digits.replace(/0+$/, "") || "0";
82
+ const newDotPos = intLen + exp;
83
+ if (digits === "0") {
84
+ result = "0";
85
+ }
86
+ else if (newDotPos <= 0) {
87
+ result = "0." + "0".repeat(-newDotPos) + digits;
88
+ }
89
+ else if (newDotPos >= digits.length) {
90
+ result = digits + "0".repeat(newDotPos - digits.length);
91
+ }
92
+ else {
93
+ result = digits.slice(0, newDotPos) + "." + digits.slice(newDotPos);
94
+ }
95
+ }
96
+ if (result.includes(".")) {
97
+ result = result.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
98
+ }
99
+ return (negative ? "-" : "") + result;
100
+ }
101
+ function expandExponentToBigInt(s) {
102
+ const eIndex = s.search(/[eE]/);
103
+ const exp = parseInt(s.slice(eIndex + 1), 10);
104
+ const negative = s.startsWith("-");
105
+ const mantissa = s.slice(negative ? 1 : 0, eIndex);
106
+ const dotIndex = mantissa.indexOf(".");
107
+ let digits;
108
+ let shift;
109
+ if (dotIndex === -1) {
110
+ digits = mantissa;
111
+ shift = exp;
112
+ }
113
+ else {
114
+ digits = mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1);
115
+ const fracDigits = mantissa.length - dotIndex - 1;
116
+ shift = exp - fracDigits;
117
+ }
118
+ digits = digits.replace(/0+$/, "") || "0";
119
+ const result = BigInt(digits) * 10n ** BigInt(shift + (mantissa.replace(".", "").length - digits.length));
120
+ return negative ? -result : result;
121
+ }
@@ -0,0 +1,41 @@
1
+ import { NormalizedSchema } from "@smithy/core/schema";
2
+ const REVIVER_SYMBOL = Symbol.for("@aws-sdk/reviver");
3
+ export function needsReviver(schema) {
4
+ const ns = NormalizedSchema.of(schema);
5
+ const raw = ns.getSchema();
6
+ if (Array.isArray(raw) && ns.isStructSchema()) {
7
+ if (REVIVER_SYMBOL in raw) {
8
+ return raw[REVIVER_SYMBOL];
9
+ }
10
+ const result = _check(ns, new Set());
11
+ raw[REVIVER_SYMBOL] = result;
12
+ return result;
13
+ }
14
+ return _check(ns, new Set());
15
+ }
16
+ function _check(ns, seen) {
17
+ const raw = ns.getSchema();
18
+ if (seen.has(raw)) {
19
+ return false;
20
+ }
21
+ seen.add(raw);
22
+ if (ns.isBigIntegerSchema() || ns.isBigDecimalSchema()) {
23
+ return true;
24
+ }
25
+ if (ns.isStructSchema()) {
26
+ for (const [, memberSchema] of ns.structIterator()) {
27
+ if (_check(memberSchema, seen)) {
28
+ return true;
29
+ }
30
+ }
31
+ }
32
+ else if (ns.isListSchema() || ns.isMapSchema()) {
33
+ if (_check(ns.getValueSchema(), seen)) {
34
+ return true;
35
+ }
36
+ }
37
+ else if (ns.isDocumentSchema()) {
38
+ return true;
39
+ }
40
+ return false;
41
+ }
@@ -0,0 +1,104 @@
1
+ import { collectBody } from "../collect-stream-body";
2
+ import { collectBodyString } from "../common";
3
+ import { detectBufferParsing } from "./detectBufferParsing";
4
+ import { jsonReviver } from "./jsonReviver";
5
+ import { needsReviver } from "./needsReviver";
6
+ export async function parseJsonBody(streamBody, context, schema) {
7
+ let parsingInput;
8
+ if (detectBufferParsing() && typeof streamBody?.[Symbol.asyncIterator] === "function") {
9
+ const buffer = await collectBody(streamBody, context);
10
+ if (typeof Buffer === "function") {
11
+ if (Buffer.isBuffer(buffer)) {
12
+ parsingInput = buffer;
13
+ }
14
+ else {
15
+ parsingInput = Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);
16
+ }
17
+ }
18
+ }
19
+ if (!parsingInput) {
20
+ parsingInput = await collectBodyString(streamBody, context);
21
+ }
22
+ if (parsingInput.length === 0) {
23
+ return {};
24
+ }
25
+ const reviver = schema && needsReviver(schema) ? jsonReviver : undefined;
26
+ try {
27
+ return JSON.parse(parsingInput, reviver);
28
+ }
29
+ catch (e) {
30
+ if (e?.name === "SyntaxError") {
31
+ Object.defineProperty(e, "$responseBodyText", {
32
+ value: typeof parsingInput === "string" ? parsingInput : parsingInput.toString("utf8"),
33
+ });
34
+ }
35
+ throw e;
36
+ }
37
+ }
38
+ export const parseJsonErrorBody = async (errorBody, context) => {
39
+ const value = await parseJsonBody(errorBody, context);
40
+ value.message = value.message ?? value.Message;
41
+ return value;
42
+ };
43
+ const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
44
+ const sanitizeErrorCode = (rawValue) => {
45
+ let cleanValue = rawValue;
46
+ if (typeof cleanValue === "number") {
47
+ cleanValue = cleanValue.toString();
48
+ }
49
+ if (cleanValue.indexOf(",") >= 0) {
50
+ cleanValue = cleanValue.split(",")[0];
51
+ }
52
+ if (cleanValue.indexOf(":") >= 0) {
53
+ cleanValue = cleanValue.split(":")[0];
54
+ }
55
+ if (cleanValue.indexOf("#") >= 0) {
56
+ cleanValue = cleanValue.split("#")[1];
57
+ }
58
+ return cleanValue;
59
+ };
60
+ export const loadRestJsonErrorCode = (output, data) => {
61
+ return loadErrorCode(output, data, ["header", "code", "type"]);
62
+ };
63
+ export const loadJsonRpcErrorCode = (output, data, queryCompat = false) => {
64
+ return loadErrorCode(output, data, queryCompat ? ["code", "header", "type"] : ["type", "code", "header"]);
65
+ };
66
+ export const loadSmithyRpcV2JsonErrorCode = (output, data) => {
67
+ if (data?.__type !== undefined) {
68
+ let cleanValue = data.__type;
69
+ if (typeof cleanValue === "number") {
70
+ cleanValue = cleanValue.toString();
71
+ }
72
+ if (cleanValue.indexOf(",") >= 0) {
73
+ cleanValue = cleanValue.split(",")[0];
74
+ }
75
+ if (cleanValue.indexOf(":") >= 0) {
76
+ cleanValue = cleanValue.split(":")[0];
77
+ }
78
+ return cleanValue;
79
+ }
80
+ };
81
+ const loadErrorCode = ({ headers }, data, order) => {
82
+ while (order.length > 0) {
83
+ const location = order.shift();
84
+ switch (location) {
85
+ case "header":
86
+ const headerKey = findKey(headers ?? {}, "x-amzn-errortype");
87
+ if (headerKey !== undefined) {
88
+ return sanitizeErrorCode(headers[headerKey]);
89
+ }
90
+ break;
91
+ case "code":
92
+ const codeKey = findKey(data ?? {}, "code");
93
+ if (codeKey && data[codeKey] !== undefined) {
94
+ return sanitizeErrorCode(data[codeKey]);
95
+ }
96
+ break;
97
+ case "type":
98
+ if (data?.__type !== undefined) {
99
+ return sanitizeErrorCode(data.__type);
100
+ }
101
+ break;
102
+ }
103
+ }
104
+ };
@@ -0,0 +1,3 @@
1
+ export function writeKey(obj) {
2
+ Object.defineProperty(obj, "__proto__", { value: undefined, writable: true, enumerable: true, configurable: true });
3
+ }
@@ -0,0 +1,8 @@
1
+ import type { ConfigurableSerdeContext, SerdeFunctions } from "@smithy/types";
2
+ /**
3
+ * @internal
4
+ */
5
+ export declare class SerdeContextConfig implements ConfigurableSerdeContext {
6
+ protected serdeContext?: SerdeFunctions;
7
+ setSerdeContext(serdeContext: SerdeFunctions): void;
8
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Helper for identifying unknown union members during deserialization.
3
+ */
4
+ export declare class UnionSerde {
5
+ private from;
6
+ private to;
7
+ private keys;
8
+ constructor(from: any, to: any);
9
+ /**
10
+ * Marks the key as being a known member.
11
+ * @param key - to mark.
12
+ */
13
+ mark(key: string): void;
14
+ /**
15
+ * @returns whether only one key remains unmarked and nothing has been written,
16
+ * implying the object is a union.
17
+ */
18
+ hasUnknown(): boolean;
19
+ /**
20
+ * Writes the unknown key-value pair, if present, into the $unknown property
21
+ * of the union object.
22
+ */
23
+ writeUnknown(): void;
24
+ }
@@ -0,0 +1,2 @@
1
+ import type { SerdeFunctions } from "@smithy/types";
2
+ export declare const collectBodyString: (streamBody: any, context: SerdeFunctions) => Promise<string>;
@@ -25,3 +25,12 @@ export { escapeUriPath } from "./util-uri-escape/escape-uri-path";
25
25
  export { buildQueryString } from "./querystring-builder/buildQueryString";
26
26
  export { parseQueryString } from "@smithy/core/transport";
27
27
  export { parseUrl } from "@smithy/core/transport";
28
+ export { SmithyRpcV2JsonProtocol } from "./json/SmithyRpcV2JsonProtocol";
29
+ export { parseJsonBody, parseJsonErrorBody, loadJsonRpcErrorCode, loadRestJsonErrorCode, loadSmithyRpcV2JsonErrorCode, } from "./json/parseJsonBody";
30
+ export type { JsonSettings } from "./json/JsonSettings";
31
+ export { JsonCodec } from "./json/codec-v1/JsonCodec";
32
+ export { JsonShapeSerializer } from "./json/codec-v1/JsonShapeSerializer";
33
+ export { JsonShapeDeserializer } from "./json/codec-v1/JsonShapeDeserializer";
34
+ export { JsonCodec2 } from "./json/codec-v2/JsonCodec2";
35
+ export { JsonShapeSerializer2 } from "./json/codec-v2/JsonShapeSerializer2";
36
+ export { JsonShapeDeserializer2 } from "./json/codec-v2/JsonShapeDeserializer2";
@@ -0,0 +1,13 @@
1
+ import type { CodecSettings } from "@smithy/types";
2
+ /**
3
+ * @public
4
+ */
5
+ export type JsonSettings = CodecSettings & {
6
+ jsonName: boolean;
7
+ /**
8
+ * When true, bigInteger and bigDecimal values are serialized as JSON strings
9
+ * to preserve arbitrary precision (Smithy RPCv2 JSON behavior). When false or
10
+ * unset, they are serialized as unquoted JSON numbers (AWS JSON 1.0/1.1 behavior).
11
+ */
12
+ bigNumberAsString?: boolean;
13
+ };
@@ -0,0 +1,28 @@
1
+ import { RpcProtocol } from "../RpcProtocol";
2
+ import { TypeRegistry } from "@smithy/core/schema";
3
+ import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";
4
+ import { JsonCodec2 } from "./codec-v2/JsonCodec2";
5
+ /**
6
+ * Client protocol for Smithy RPCv2 JSON.
7
+ *
8
+ * @public
9
+ */
10
+ export declare class SmithyRpcV2JsonProtocol extends RpcProtocol {
11
+ /**
12
+ * @override
13
+ */
14
+ protected compositeErrorRegistry: TypeRegistry;
15
+ private codec;
16
+ protected serializer: ShapeSerializer<string | Uint8Array>;
17
+ protected deserializer: ShapeDeserializer<string | Uint8Array>;
18
+ constructor({ defaultNamespace, errorTypeRegistries, }: {
19
+ defaultNamespace: string;
20
+ errorTypeRegistries?: TypeRegistry[];
21
+ });
22
+ getShapeId(): string;
23
+ getPayloadCodec(): JsonCodec2;
24
+ serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
25
+ deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
26
+ protected handleError(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse, dataObject: any, metadata: ResponseMetadata): Promise<never>;
27
+ protected getDefaultContentType(): string;
28
+ }
@@ -0,0 +1,15 @@
1
+ import type { Codec } from "@smithy/types";
2
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
3
+ import { JsonShapeDeserializer } from "./JsonShapeDeserializer";
4
+ import { JsonShapeSerializer } from "./JsonShapeSerializer";
5
+ import type { JsonSettings } from "./JsonSettings";
6
+ /**
7
+ * @deprecated use JsonCodec2.
8
+ * @public
9
+ */
10
+ export declare class JsonCodec extends SerdeContextConfig implements Codec<string, string> {
11
+ readonly settings: JsonSettings;
12
+ constructor(settings: JsonSettings);
13
+ createSerializer(): JsonShapeSerializer;
14
+ createDeserializer(): JsonShapeDeserializer;
15
+ }
@@ -0,0 +1,7 @@
1
+ import type { CodecSettings } from "@smithy/types";
2
+ /**
3
+ * @public
4
+ */
5
+ export type JsonSettings = CodecSettings & {
6
+ jsonName: boolean;
7
+ };
@@ -0,0 +1,14 @@
1
+ import type { DocumentType, Schema, ShapeDeserializer } from "@smithy/types";
2
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
3
+ import type { JsonSettings } from "./JsonSettings";
4
+ /**
5
+ * @deprecated prefer JsonShapeDeserializer in codec-v2.
6
+ * @public
7
+ */
8
+ export declare class JsonShapeDeserializer extends SerdeContextConfig implements ShapeDeserializer<string> {
9
+ readonly settings: JsonSettings;
10
+ constructor(settings: JsonSettings);
11
+ read(schema: Schema, data: string | Uint8Array | unknown): Promise<any>;
12
+ readObject(schema: Schema, data: DocumentType): any;
13
+ protected _read(schema: Schema, value: unknown): any;
14
+ }
@@ -0,0 +1,29 @@
1
+ import { NormalizedSchema } from "@smithy/core/schema";
2
+ import type { Schema, ShapeSerializer } from "@smithy/types";
3
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
4
+ import type { JsonSettings } from "./JsonSettings";
5
+ /**
6
+ * @deprecated prefer byte-targeting JsonShapeSerializer or its string adapter StringJsonShapeSerializer in codec-v2.
7
+ * @public
8
+ */
9
+ export declare class JsonShapeSerializer extends SerdeContextConfig implements ShapeSerializer<string> {
10
+ readonly settings: JsonSettings;
11
+ /**
12
+ * Write buffer. Reused per value serialization pass.
13
+ * In the initial implementation, this is not an incremental buffer.
14
+ */
15
+ protected buffer: any;
16
+ protected useReplacer: boolean;
17
+ protected rootSchema: NormalizedSchema | undefined;
18
+ constructor(settings: JsonSettings);
19
+ write(schema: Schema, value: unknown): void;
20
+ flush(): string;
21
+ /**
22
+ * @internal
23
+ */
24
+ writeDiscriminatedDocument(schema: Schema, value: unknown): void;
25
+ /**
26
+ * Order if-statements by likelihood.
27
+ */
28
+ protected _write(schema: Schema, value: unknown, container?: NormalizedSchema): any;
29
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * A Uint8Array subclass holding serialized JSON bytes that provides
3
+ * string method compatibility for customer middleware.
4
+ *
5
+ * Middleware historically observed `request.body` as a string for JSON
6
+ * protocol services. This class preserves that contract: string methods
7
+ * and coercion (template literals, `+` operator) lazily decode the bytes
8
+ * to a cached string. The HTTP transport layer still sees a Uint8Array
9
+ * and sends raw bytes without conversion.
10
+ *
11
+ * @internal
12
+ * @deprecated this adapter will be removed in a future version.
13
+ */
14
+ export declare class JsonBytesStringAdapter extends Uint8Array {
15
+ private string;
16
+ static allocUnsafe(bytes: number): JsonBytesStringAdapter;
17
+ /**
18
+ * Enables string coercion via template literals and `+` operator.
19
+ */
20
+ toString(): string;
21
+ /**
22
+ * Enables string coercion in comparison and arithmetic contexts.
23
+ * @returns a string. The signature is set to avoid incompatibility with extending Uint8Array.
24
+ */
25
+ valueOf(): any;
26
+ includes(searchString: string | number, position?: number): boolean;
27
+ indexOf(searchString: string | number, position?: number): number;
28
+ lastIndexOf(searchString: string | number, position?: number): number;
29
+ startsWith(searchString: string, position?: number): boolean;
30
+ endsWith(searchString: string, endPosition?: number): boolean;
31
+ match(regexp: string | RegExp): RegExpMatchArray | null;
32
+ replace(searchValue: string | RegExp, replaceValue: string): string;
33
+ search(regexp: string | RegExp): number;
34
+ split(separator: string | RegExp, limit?: number): string[];
35
+ substring(start: number, end?: number): string;
36
+ trim(): string;
37
+ trimStart(): string;
38
+ trimEnd(): string;
39
+ charAt(pos: number): string;
40
+ charCodeAt(index: number): number;
41
+ padStart(maxLength: number, fillString?: string): string;
42
+ padEnd(maxLength: number, fillString?: string): string;
43
+ repeat(count: number): string;
44
+ toUpperCase(): string;
45
+ toLowerCase(): string;
46
+ /**
47
+ * Decodes the bytes to a UTF-8 string on first access, then caches.
48
+ * Subsequent calls return the cached string with zero cost.
49
+ */
50
+ private s;
51
+ }
@@ -0,0 +1,13 @@
1
+ import type { $ShapeSerializer, $Codec, $ShapeDeserializer } from "@smithy/types";
2
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
3
+ import type { JsonSettings } from "../JsonSettings";
4
+ /**
5
+ * Codec grouping the v2 serializer and deserializer.
6
+ * @public
7
+ */
8
+ export declare class JsonCodec2 extends SerdeContextConfig implements $Codec<Uint8Array, string> {
9
+ readonly settings: JsonSettings;
10
+ constructor(settings: JsonSettings);
11
+ createSerializer(): $ShapeSerializer<Uint8Array>;
12
+ createDeserializer(): $ShapeDeserializer<string>;
13
+ }
@@ -0,0 +1,30 @@
1
+ import type { DocumentType, Schema, ShapeDeserializer } from "@smithy/types";
2
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
3
+ import type { JsonSettings } from "../JsonSettings";
4
+ /**
5
+ * Performance-optimized JSON deserializer.
6
+ *
7
+ * Skips UTF-8 decoding when the runtime supports JSON.parse(Buffer) (Node 22+).
8
+ *
9
+ * After JSON.parse, lists, maps, and document containers are mutated in place
10
+ * (element values are overwritten with their deserialized form) rather than
11
+ * copied into new arrays/objects. Structs allocate a fresh object because
12
+ * jsonName traits require key renaming, and building the output object
13
+ * incrementally lets V8 assign a stable hidden class rather than
14
+ * deoptimizing from repeated property deletion/addition on an existing shape.
15
+ *
16
+ * In-place mutation is safe here because the parsed tree is locally owned
17
+ * after JSON.parse with no external references, so rewriting values avoids
18
+ * redundant allocation and GC pressure.
19
+ *
20
+ * @public
21
+ */
22
+ export declare class JsonShapeDeserializer2 extends SerdeContextConfig implements ShapeDeserializer<string> {
23
+ readonly settings: JsonSettings;
24
+ constructor(settings: JsonSettings);
25
+ read(schema: Schema, data: string | Uint8Array | unknown): Promise<any>;
26
+ readObject(schema: Schema, data: DocumentType): any;
27
+ protected _read(schema: Schema, value: unknown): any;
28
+ private _readStruct;
29
+ private needsTransform;
30
+ }
@@ -0,0 +1,60 @@
1
+ import { NormalizedSchema } from "@smithy/core/schema";
2
+ import type { Schema, ShapeSerializer } from "@smithy/types";
3
+ import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
4
+ import type { JsonSettings } from "../JsonSettings";
5
+ /**
6
+ * Single-pass JSON serializer that writes directly to a Uint8Array buffer.
7
+ * Fewer intermediate states as when compared to the initial multi-pass implementation.
8
+ *
9
+ * @public
10
+ */
11
+ export declare class JsonShapeSerializer2 extends SerdeContextConfig implements ShapeSerializer<Uint8Array> {
12
+ readonly settings: JsonSettings;
13
+ private json;
14
+ private i;
15
+ private rootSchema;
16
+ private rawValue;
17
+ private passthrough;
18
+ constructor(settings: JsonSettings);
19
+ write(schema: Schema, value: unknown): void;
20
+ /**
21
+ * @internal
22
+ */
23
+ writeDiscriminatedDocument(schema: Schema, value: unknown): void;
24
+ /**
25
+ * Returns the serialized JSON as a Uint8Array (UTF-8 bytes).
26
+ * This is the primary output — pass directly to request.body.
27
+ */
28
+ flush(): Uint8Array;
29
+ protected ensure(byteCount: number): void;
30
+ /**
31
+ * Write a raw ASCII string (no JSON escaping). Used for pre-validated content
32
+ * like numeric literals and pre-encoded base64.
33
+ */
34
+ protected writeAscii(s: string): void;
35
+ /**
36
+ * Write a quoted ASCII string with no escape checking.
37
+ * Used for struct member keys (jsonName or model names) which are
38
+ * guaranteed to be safe ASCII identifiers. No control chars, quotes,
39
+ * backslashes, or non-ASCII.
40
+ * Ensures extra room for surrounding structural chars (comma, colon).
41
+ */
42
+ protected writeAsciiQuoted(s: string): void;
43
+ /**
44
+ * Write a JSON-escaped string including the surrounding quotes.
45
+ * Fast-path for ASCII, falls back to TextEncoder for multi-byte.
46
+ */
47
+ protected writeJsonString(s: string): void;
48
+ protected writeUnicodeEscape(code: number): void;
49
+ protected static readonly B64: Uint8Array;
50
+ /**
51
+ * Write a Uint8Array as a quoted base64 string directly into the buffer.
52
+ * No intermediate JS string, no escape checking (base64 alphabet is safe ASCII).
53
+ */
54
+ protected writeBase64(data: Uint8Array): void;
55
+ protected writeValue(schema: Schema, value: unknown, container: NormalizedSchema | undefined): void;
56
+ protected writeStruct(ns: NormalizedSchema, value: Record<string, unknown>): void;
57
+ protected writeList(ns: NormalizedSchema, value: unknown[], isDocument?: boolean): void;
58
+ protected writeMap(ns: NormalizedSchema, value: Record<string, unknown>, isDocument?: boolean): void;
59
+ protected writeTimestamp(ns: NormalizedSchema, value: Date): void;
60
+ }
@@ -0,0 +1 @@
1
+ export declare function detectBufferParsing(): boolean;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Serializes BigInt and NumericValue to JSON-number.
3
+ * @internal
4
+ */
5
+ export declare class JsonReplacer {
6
+ /**
7
+ * Stores placeholder key to true serialized value lookup.
8
+ */
9
+ private readonly values;
10
+ private counter;
11
+ private stage;
12
+ /**
13
+ * Creates a jsonReplacer function that reserves big integer and big decimal values
14
+ * for later replacement.
15
+ */
16
+ createReplacer(): (key: string, value: unknown) => unknown;
17
+ /**
18
+ * Replaces placeholder keys with their true values.
19
+ */
20
+ replaceInJson(json: string): string;
21
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @param key - JSON object key.
3
+ * @param value - parsed value.
4
+ * @param context - original JSON string for reference. Not available until Node.js 21 and unavailable in Safari as
5
+ * of April 2025.
6
+ *
7
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#browser_compatibility
8
+ *
9
+ * @internal
10
+ *
11
+ * @returns transformed value.
12
+ */
13
+ export declare function jsonReviver(key: string, value: any, context?: {
14
+ source?: string;
15
+ }): any;
@@ -0,0 +1,11 @@
1
+ import type { Schema } from "@smithy/types";
2
+ /**
3
+ * Determines whether a schema tree contains BigInteger or BigDecimal members,
4
+ * which require a JSON.parse reviver to preserve numeric precision.
5
+ *
6
+ * The result is cached on the root static schema array (struct schemas) via a Symbol key,
7
+ * so subsequent calls for the same schema are O(1).
8
+ *
9
+ * @internal
10
+ */
11
+ export declare function needsReviver(schema: Schema): boolean;