@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.
- package/.jsii +3 -3
- package/lib/resolve.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/dist-cjs/index.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/package.json +1 -1
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +1695 -3
- package/node_modules/@smithy/core/dist-es/submodules/protocols/ConfigurableSerdeContext.js +6 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/UnionSerde.js +26 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/common.js +3 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +8 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/JsonSettings.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/SmithyRpcV2JsonProtocol.js +102 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js +20 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v1/JsonSettings.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js +167 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js +200 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.js +103 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js +20 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js +211 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js +529 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/detectBufferParsing.js +18 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/jsonReplacer.js +46 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/jsonReviver.js +121 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/needsReviver.js +41 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/json/parseJsonBody.js +104 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/writeKey.js +3 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/ConfigurableSerdeContext.d.ts +8 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/UnionSerde.d.ts +24 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/common.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/index.d.ts +9 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/JsonSettings.d.ts +13 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/SmithyRpcV2JsonProtocol.d.ts +28 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v1/JsonCodec.d.ts +15 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v1/JsonSettings.d.ts +7 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +14 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +29 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +51 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v2/JsonCodec2.d.ts +13 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +30 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +60 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/detectBufferParsing.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/jsonReplacer.d.ts +21 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/jsonReviver.d.ts +15 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/needsReviver.d.ts +11 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/json/parseJsonBody.d.ts +38 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/writeKey.d.ts +4 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/ConfigurableSerdeContext.d.ts +8 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/UnionSerde.d.ts +24 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/common.d.ts +2 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/index.d.ts +9 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/JsonSettings.d.ts +13 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/SmithyRpcV2JsonProtocol.d.ts +28 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonCodec.d.ts +15 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonSettings.d.ts +7 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeDeserializer.d.ts +14 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v1/JsonShapeSerializer.d.ts +29 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.d.ts +51 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonCodec2.d.ts +13 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.d.ts +30 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/codec-v2/JsonShapeSerializer2.d.ts +60 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/detectBufferParsing.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/jsonReplacer.d.ts +21 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/jsonReviver.d.ts +15 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/needsReviver.d.ts +11 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/json/parseJsonBody.d.ts +38 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/writeKey.d.ts +4 -0
- package/node_modules/@smithy/core/package.json +2 -1
- package/package.json +3 -3
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { determineTimestampFormat } from "../../serde/determineTimestampFormat";
|
|
2
|
+
import { NormalizedSchema } from "@smithy/core/schema";
|
|
3
|
+
import { fromBase64, LazyJsonString, NumericValue, parseEpochTimestamp, parseRfc3339DateTimeWithOffset, parseRfc7231DateTime, } from "@smithy/core/serde";
|
|
4
|
+
import { SerdeContextConfig } from "../../ConfigurableSerdeContext";
|
|
5
|
+
import { UnionSerde } from "../../UnionSerde";
|
|
6
|
+
import { detectBufferParsing } from "../detectBufferParsing";
|
|
7
|
+
import { jsonReviver } from "../jsonReviver";
|
|
8
|
+
import { needsReviver } from "../needsReviver";
|
|
9
|
+
import { parseJsonBody } from "../parseJsonBody";
|
|
10
|
+
import { writeKey } from "../../writeKey";
|
|
11
|
+
import { hasOwn } from "@smithy/core/transport";
|
|
12
|
+
export class JsonShapeDeserializer2 extends SerdeContextConfig {
|
|
13
|
+
settings;
|
|
14
|
+
constructor(settings) {
|
|
15
|
+
super();
|
|
16
|
+
this.settings = settings;
|
|
17
|
+
}
|
|
18
|
+
async read(schema, data) {
|
|
19
|
+
const reviver = needsReviver(schema) ? jsonReviver : undefined;
|
|
20
|
+
let parsed;
|
|
21
|
+
if (typeof data === "string") {
|
|
22
|
+
if (data.length === 0) {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
parsed = JSON.parse(data, reviver);
|
|
26
|
+
}
|
|
27
|
+
else if (data instanceof Uint8Array && detectBufferParsing()) {
|
|
28
|
+
if (data.byteLength === 0) {
|
|
29
|
+
return {};
|
|
30
|
+
}
|
|
31
|
+
const buf = Buffer.isBuffer(data) ? data : Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
|
32
|
+
parsed = JSON.parse(buf, reviver);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
parsed = await parseJsonBody(data, this.serdeContext, schema);
|
|
36
|
+
}
|
|
37
|
+
return this._read(schema, parsed);
|
|
38
|
+
}
|
|
39
|
+
readObject(schema, data) {
|
|
40
|
+
return this._read(schema, data);
|
|
41
|
+
}
|
|
42
|
+
_read(schema, value) {
|
|
43
|
+
const isObject = value !== null && typeof value === "object";
|
|
44
|
+
const ns = NormalizedSchema.of(schema);
|
|
45
|
+
if (isObject) {
|
|
46
|
+
if (ns.isStructSchema()) {
|
|
47
|
+
return this._readStruct(ns, value);
|
|
48
|
+
}
|
|
49
|
+
if (Array.isArray(value) && ns.isListSchema()) {
|
|
50
|
+
const listMember = ns.getValueSchema();
|
|
51
|
+
if (this.needsTransform(listMember)) {
|
|
52
|
+
for (let i = 0; i < value.length; ++i) {
|
|
53
|
+
value[i] = this._read(listMember, value[i]);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
if (ns.isMapSchema()) {
|
|
59
|
+
const mapMember = ns.getValueSchema();
|
|
60
|
+
const map = value;
|
|
61
|
+
if (this.needsTransform(mapMember)) {
|
|
62
|
+
for (const k in map) {
|
|
63
|
+
if (!hasOwn(map, k))
|
|
64
|
+
continue;
|
|
65
|
+
if (k === "__proto__") {
|
|
66
|
+
writeKey(map);
|
|
67
|
+
}
|
|
68
|
+
map[k] = this._read(mapMember, map[k]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return map;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (ns.isBlobSchema() && typeof value === "string") {
|
|
75
|
+
return fromBase64(value);
|
|
76
|
+
}
|
|
77
|
+
const mediaType = ns.getMergedTraits().mediaType;
|
|
78
|
+
if (ns.isStringSchema() && typeof value === "string" && mediaType) {
|
|
79
|
+
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
|
80
|
+
if (isJson) {
|
|
81
|
+
return LazyJsonString.from(value);
|
|
82
|
+
}
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
if (ns.isTimestampSchema() && value != null) {
|
|
86
|
+
const format = determineTimestampFormat(ns, this.settings);
|
|
87
|
+
switch (format) {
|
|
88
|
+
case 5:
|
|
89
|
+
return parseRfc3339DateTimeWithOffset(value);
|
|
90
|
+
case 6:
|
|
91
|
+
return parseRfc7231DateTime(value);
|
|
92
|
+
case 7:
|
|
93
|
+
return parseEpochTimestamp(value);
|
|
94
|
+
default:
|
|
95
|
+
console.warn("Missing timestamp format, parsing value with Date constructor:", value);
|
|
96
|
+
return new Date(value);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (ns.isBigIntegerSchema() && (typeof value === "number" || typeof value === "string")) {
|
|
100
|
+
return BigInt(value);
|
|
101
|
+
}
|
|
102
|
+
if (ns.isBigDecimalSchema() && value != undefined) {
|
|
103
|
+
if (value instanceof NumericValue) {
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
const untyped = value;
|
|
107
|
+
if (untyped.type === "bigDecimal" && "string" in untyped) {
|
|
108
|
+
return new NumericValue(untyped.string, untyped.type);
|
|
109
|
+
}
|
|
110
|
+
return new NumericValue(String(value), "bigDecimal");
|
|
111
|
+
}
|
|
112
|
+
if (ns.isNumericSchema() && typeof value === "string") {
|
|
113
|
+
switch (value) {
|
|
114
|
+
case "Infinity":
|
|
115
|
+
return Infinity;
|
|
116
|
+
case "-Infinity":
|
|
117
|
+
return -Infinity;
|
|
118
|
+
case "NaN":
|
|
119
|
+
return NaN;
|
|
120
|
+
}
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
if (ns.isDocumentSchema()) {
|
|
124
|
+
if (isObject) {
|
|
125
|
+
if (Array.isArray(value)) {
|
|
126
|
+
for (let i = 0; i < value.length; ++i) {
|
|
127
|
+
const v = value[i];
|
|
128
|
+
if (!(v instanceof NumericValue)) {
|
|
129
|
+
value[i] = this._read(ns, v);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
const doc = value;
|
|
135
|
+
for (const k in doc) {
|
|
136
|
+
if (!hasOwn(doc, k))
|
|
137
|
+
continue;
|
|
138
|
+
if (k === "__proto__") {
|
|
139
|
+
writeKey(doc);
|
|
140
|
+
}
|
|
141
|
+
const v = doc[k];
|
|
142
|
+
if (!(v instanceof NumericValue)) {
|
|
143
|
+
doc[k] = this._read(ns, v);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
|
+
_readStruct(ns, record) {
|
|
152
|
+
const union = ns.isUnionSchema();
|
|
153
|
+
const out = {};
|
|
154
|
+
let nameMap;
|
|
155
|
+
const hasType = typeof record.__type === "string";
|
|
156
|
+
const { jsonName } = this.settings;
|
|
157
|
+
if (jsonName && hasType) {
|
|
158
|
+
nameMap = {};
|
|
159
|
+
}
|
|
160
|
+
let unionSerde;
|
|
161
|
+
if (union) {
|
|
162
|
+
unionSerde = new UnionSerde(record, out);
|
|
163
|
+
}
|
|
164
|
+
for (const [memberName, memberSchema] of ns.structIterator()) {
|
|
165
|
+
let fromKey = memberName;
|
|
166
|
+
if (jsonName) {
|
|
167
|
+
fromKey = memberSchema.getMergedTraits().jsonName ?? fromKey;
|
|
168
|
+
if (hasType) {
|
|
169
|
+
nameMap[fromKey] = memberName;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (union) {
|
|
173
|
+
unionSerde.mark(fromKey);
|
|
174
|
+
}
|
|
175
|
+
if (record[fromKey] != null) {
|
|
176
|
+
out[memberName] = this._read(memberSchema, record[fromKey]);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (union) {
|
|
180
|
+
unionSerde.writeUnknown();
|
|
181
|
+
}
|
|
182
|
+
else if (hasType) {
|
|
183
|
+
for (const k in record) {
|
|
184
|
+
if (!hasOwn(record, k))
|
|
185
|
+
continue;
|
|
186
|
+
const v = record[k];
|
|
187
|
+
const t = jsonName ? (nameMap[k] ?? k) : k;
|
|
188
|
+
if (!(t in out)) {
|
|
189
|
+
out[t] = v;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return out;
|
|
194
|
+
}
|
|
195
|
+
needsTransform(ns) {
|
|
196
|
+
if (ns.isBlobSchema() ||
|
|
197
|
+
ns.isTimestampSchema() ||
|
|
198
|
+
ns.isBigIntegerSchema() ||
|
|
199
|
+
ns.isBigDecimalSchema() ||
|
|
200
|
+
ns.isNumericSchema()) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
if (ns.isDocumentSchema() || ns.isStructSchema() || ns.isListSchema() || ns.isMapSchema()) {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
if (ns.isStringSchema() && ns.getMergedTraits().mediaType) {
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
}
|