@granite-js/pulumi-aws 0.1.34 → 1.0.1
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/CHANGELOG.md +4 -116
- package/dist/chunk-23MVQUOJ.js +1630 -0
- package/dist/chunk-24XYHOWM.js +171 -0
- package/dist/chunk-3AVBP57V.js +1598 -0
- package/dist/chunk-3JKQPIJ2.js +460 -0
- package/dist/{chunk-ITI6QA2Q.js → chunk-3OYGHA4S.js} +1 -1
- package/dist/{chunk-IEZY5C3G.js → chunk-46DIC54Q.js} +49 -37
- package/dist/chunk-57WYIP4I.js +808 -0
- package/dist/{chunk-WCHHWTND.js → chunk-63Q3RLAK.js} +93 -59
- package/dist/chunk-6KRYZP6R.js +28 -0
- package/dist/{chunk-QAE2S7MG.js → chunk-7NN7DVGK.js} +2050 -552
- package/dist/{chunk-5W7B34BN.js → chunk-ASGFIK4A.js} +2231 -464
- package/dist/chunk-BTBQTDRJ.js +174 -0
- package/dist/chunk-DDZTWBHZ.js +154 -0
- package/dist/chunk-G3FWLTNJ.js +10 -0
- package/dist/{chunk-TJ744C2T.js → chunk-GJFKL6XM.js} +43 -38
- package/dist/chunk-H4QJ5O4E.js +36 -0
- package/dist/{chunk-X6XO7USX.js → chunk-LCO5F3JB.js} +109 -56
- package/dist/chunk-NDDYFDCU.js +60 -0
- package/dist/chunk-OCHPLE5N.js +28 -0
- package/dist/chunk-OSJA4YYQ.js +846 -0
- package/dist/chunk-PIT3K3NC.js +464 -0
- package/dist/chunk-QCKAO4UT.js +476 -0
- package/dist/{chunk-64IS37V6.js → chunk-RYIGWCGK.js} +1 -6
- package/dist/chunk-S4LJWEXU.js +37 -0
- package/dist/chunk-SJ26Y3GW.js +472 -0
- package/dist/chunk-TDZTH7TL.js +60 -0
- package/dist/chunk-THUA35UY.js +35 -0
- package/dist/{chunk-IUKLHJNE.js → chunk-V7TRGEV6.js} +4 -7
- package/dist/{chunk-KGNTV362.js → chunk-WDFKVCPC.js} +66 -34
- package/dist/{chunk-B7OAPHPY.js → chunk-YWWEFWFD.js} +3 -3
- package/dist/chunk-Z4UYYQ4J.js +42 -0
- package/dist/chunk-ZBT5SDIQ.js +16528 -0
- package/dist/chunk-ZIHRRTTA.js +24 -0
- package/dist/{dist-es-CDFIYJVE.js → dist-es-3VZ2IGGJ.js} +18 -15
- package/dist/{dist-es-SUPEA6VE-3B5JSW5C.js → dist-es-BQW4ETQH-C7ZSD5EG.js} +8 -25
- package/dist/{dist-es-GHYMLBON.js → dist-es-HSWXMGNC.js} +21 -21
- package/dist/{dist-es-OCQVKISC-TNAJ62WG.js → dist-es-IDBNBAO5-H3TO63FG.js} +15 -18
- package/dist/{dist-es-S75EKWRJ.js → dist-es-KPJNIAPT.js} +9 -10
- package/dist/{dist-es-PRWCVZGQ-HTTVI42T.js → dist-es-LZDRG6RP-SP2FWWEO.js} +3 -4
- package/dist/{dist-es-OZGLUDWT.js → dist-es-PIWY5TOR.js} +49 -26
- package/dist/{dist-es-ADTONJUN-RVFWNZHO.js → dist-es-R4LD2OHZ-B5MB6BR2.js} +11 -13
- package/dist/dist-es-S2KJK4L2-5GDBXJIO.js +470 -0
- package/dist/{dist-es-XQME5F6W.js → dist-es-THYWPEKB.js} +12 -10
- package/dist/{dist-es-HJVOMDYC-PIAMWMAL.js → dist-es-TIYLKN6W-BAHZRZH5.js} +7 -13
- package/dist/{dist-es-IDBDK36G-Y6TQMRO5.js → dist-es-VORPMM2F-WOMP2FYQ.js} +37 -30
- package/dist/{dist-es-WQHDOVD7.js → dist-es-WESJCADT.js} +3 -4
- package/dist/dist-es-XMOG24OT.js +490 -0
- package/dist/event-streams-L7RH32OW-AFMBEYJJ.js +237 -0
- package/dist/event-streams-NGUY2RWE.js +237 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/lambda/auto-cache-removal.cjs +28894 -16488
- package/dist/lambda/auto-cache-removal.js +11574 -2713
- package/dist/lambda/origin-request.cjs +22351 -17619
- package/dist/lambda/origin-request.js +21 -17
- package/dist/lambda/origin-response.cjs +22219 -17387
- package/dist/lambda/origin-response.js +17 -13
- package/dist/{loadSso-CZSSLFH6-SA5HOQAX.js → loadSso-F4PTCHDN-YR3RRUYW.js} +330 -227
- package/dist/{loadSso-T7GJVVO2.js → loadSso-LG7MFP7N.js} +344 -223
- package/dist/signin-P7DNG43W.js +658 -0
- package/dist/signin-XWTOVLF3-4ENWNEF7.js +630 -0
- package/dist/{sso-oidc-PKO5GYK5-LC65L46O.js → sso-oidc-FQQGUOJL.js} +293 -332
- package/dist/{sso-oidc-55SJ27II.js → sso-oidc-RRDYLOJY-FK3AUTOI.js} +263 -337
- package/dist/{sts-OPF4H3GL.js → sts-7FBOVTCN.js} +674 -601
- package/dist/{sts-P7Q3MYTS-BKGWHQE4.js → sts-TBWJ374A-DHXXCVJJ.js} +651 -608
- package/package.json +5 -5
- package/dist/chunk-AEOST5WF.js +0 -63
- package/dist/chunk-FO7L563E.js +0 -13695
- package/dist/chunk-FRWSD3YQ.js +0 -1722
- package/dist/chunk-JBVMOFGH.js +0 -152
- package/dist/chunk-JSBRDJBE.js +0 -30
- package/dist/chunk-KRJS4RAS.js +0 -1732
- package/dist/chunk-M5GUUX64.js +0 -63
- package/dist/chunk-SX6SVQKS.js +0 -67
- package/dist/chunk-UNXXS5FM.js +0 -120
- package/dist/chunk-UT2RMOJS.js +0 -2447
- package/dist/chunk-VOTRVWIB.js +0 -1965
- package/dist/chunk-W3VXP3A3.js +0 -119
- package/dist/chunk-XLUI7RQ4.js +0 -115
- package/dist/dist-es-2M7RLZ5O.js +0 -200
- package/dist/dist-es-Y7VN37H5-WQ3GYROF.js +0 -196
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HttpBindingProtocol,
|
|
3
|
+
HttpInterceptingShapeDeserializer,
|
|
4
|
+
HttpInterceptingShapeSerializer,
|
|
5
|
+
collectBodyString
|
|
6
|
+
} from "./chunk-3JKQPIJ2.js";
|
|
7
|
+
import {
|
|
8
|
+
LazyJsonString,
|
|
9
|
+
NormalizedSchema,
|
|
10
|
+
NumericValue,
|
|
11
|
+
ProtocolLib,
|
|
12
|
+
SerdeContextConfig,
|
|
13
|
+
TypeRegistry,
|
|
14
|
+
deserializingStructIterator,
|
|
15
|
+
determineTimestampFormat,
|
|
16
|
+
serializingStructIterator,
|
|
17
|
+
v4
|
|
18
|
+
} from "./chunk-7NN7DVGK.js";
|
|
19
|
+
import {
|
|
20
|
+
dateToUtcString,
|
|
21
|
+
fromBase64,
|
|
22
|
+
parseEpochTimestamp,
|
|
23
|
+
parseRfc3339DateTimeWithOffset,
|
|
24
|
+
parseRfc7231DateTime,
|
|
25
|
+
toBase64
|
|
26
|
+
} from "./chunk-57WYIP4I.js";
|
|
27
|
+
|
|
28
|
+
// ../deployment-manager/dist/chunk-JUOTBTCX.js
|
|
29
|
+
function jsonReviver(key, value, context) {
|
|
30
|
+
if (context?.source) {
|
|
31
|
+
const numericString = context.source;
|
|
32
|
+
if (typeof value === "number") {
|
|
33
|
+
if (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER || numericString !== String(value)) {
|
|
34
|
+
const isFractional = numericString.includes(".");
|
|
35
|
+
if (isFractional) {
|
|
36
|
+
return new NumericValue(numericString, "bigDecimal");
|
|
37
|
+
} else {
|
|
38
|
+
return BigInt(numericString);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
var parseJsonBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
|
|
46
|
+
if (encoded.length) {
|
|
47
|
+
try {
|
|
48
|
+
return JSON.parse(encoded);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
if (e?.name === "SyntaxError") {
|
|
51
|
+
Object.defineProperty(e, "$responseBodyText", {
|
|
52
|
+
value: encoded
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
throw e;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {};
|
|
59
|
+
});
|
|
60
|
+
var loadRestJsonErrorCode = (output, data) => {
|
|
61
|
+
const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
|
|
62
|
+
const sanitizeErrorCode = (rawValue) => {
|
|
63
|
+
let cleanValue = rawValue;
|
|
64
|
+
if (typeof cleanValue === "number") {
|
|
65
|
+
cleanValue = cleanValue.toString();
|
|
66
|
+
}
|
|
67
|
+
if (cleanValue.indexOf(",") >= 0) {
|
|
68
|
+
cleanValue = cleanValue.split(",")[0];
|
|
69
|
+
}
|
|
70
|
+
if (cleanValue.indexOf(":") >= 0) {
|
|
71
|
+
cleanValue = cleanValue.split(":")[0];
|
|
72
|
+
}
|
|
73
|
+
if (cleanValue.indexOf("#") >= 0) {
|
|
74
|
+
cleanValue = cleanValue.split("#")[1];
|
|
75
|
+
}
|
|
76
|
+
return cleanValue;
|
|
77
|
+
};
|
|
78
|
+
const headerKey = findKey(output.headers, "x-amzn-errortype");
|
|
79
|
+
if (headerKey !== void 0) {
|
|
80
|
+
return sanitizeErrorCode(output.headers[headerKey]);
|
|
81
|
+
}
|
|
82
|
+
if (data && typeof data === "object") {
|
|
83
|
+
const codeKey = findKey(data, "code");
|
|
84
|
+
if (codeKey && data[codeKey] !== void 0) {
|
|
85
|
+
return sanitizeErrorCode(data[codeKey]);
|
|
86
|
+
}
|
|
87
|
+
if (data["__type"] !== void 0) {
|
|
88
|
+
return sanitizeErrorCode(data["__type"]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var JsonShapeDeserializer = class extends SerdeContextConfig {
|
|
93
|
+
settings;
|
|
94
|
+
constructor(settings) {
|
|
95
|
+
super();
|
|
96
|
+
this.settings = settings;
|
|
97
|
+
}
|
|
98
|
+
async read(schema, data) {
|
|
99
|
+
return this._read(schema, typeof data === "string" ? JSON.parse(data, jsonReviver) : await parseJsonBody(data, this.serdeContext));
|
|
100
|
+
}
|
|
101
|
+
readObject(schema, data) {
|
|
102
|
+
return this._read(schema, data);
|
|
103
|
+
}
|
|
104
|
+
_read(schema, value) {
|
|
105
|
+
const isObject = value !== null && typeof value === "object";
|
|
106
|
+
const ns = NormalizedSchema.of(schema);
|
|
107
|
+
if (ns.isListSchema() && Array.isArray(value)) {
|
|
108
|
+
const listMember = ns.getValueSchema();
|
|
109
|
+
const out = [];
|
|
110
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
111
|
+
for (const item of value) {
|
|
112
|
+
if (sparse || item != null) {
|
|
113
|
+
out.push(this._read(listMember, item));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return out;
|
|
117
|
+
} else if (ns.isMapSchema() && isObject) {
|
|
118
|
+
const mapMember = ns.getValueSchema();
|
|
119
|
+
const out = {};
|
|
120
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
121
|
+
for (const [_k, _v] of Object.entries(value)) {
|
|
122
|
+
if (sparse || _v != null) {
|
|
123
|
+
out[_k] = this._read(mapMember, _v);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return out;
|
|
127
|
+
} else if (ns.isStructSchema() && isObject) {
|
|
128
|
+
const out = {};
|
|
129
|
+
for (const [memberName, memberSchema] of deserializingStructIterator(ns, value, this.settings.jsonName ? "jsonName" : false)) {
|
|
130
|
+
const fromKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
|
|
131
|
+
const deserializedValue = this._read(memberSchema, value[fromKey]);
|
|
132
|
+
if (deserializedValue != null) {
|
|
133
|
+
out[memberName] = deserializedValue;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
if (ns.isBlobSchema() && typeof value === "string") {
|
|
139
|
+
return fromBase64(value);
|
|
140
|
+
}
|
|
141
|
+
const mediaType = ns.getMergedTraits().mediaType;
|
|
142
|
+
if (ns.isStringSchema() && typeof value === "string" && mediaType) {
|
|
143
|
+
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
|
144
|
+
if (isJson) {
|
|
145
|
+
return LazyJsonString.from(value);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (ns.isTimestampSchema() && value != null) {
|
|
149
|
+
const format = determineTimestampFormat(ns, this.settings);
|
|
150
|
+
switch (format) {
|
|
151
|
+
case 5:
|
|
152
|
+
return parseRfc3339DateTimeWithOffset(value);
|
|
153
|
+
case 6:
|
|
154
|
+
return parseRfc7231DateTime(value);
|
|
155
|
+
case 7:
|
|
156
|
+
return parseEpochTimestamp(value);
|
|
157
|
+
default:
|
|
158
|
+
console.warn("Missing timestamp format, parsing value with Date constructor:", value);
|
|
159
|
+
return new Date(value);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (ns.isBigIntegerSchema() && (typeof value === "number" || typeof value === "string")) {
|
|
163
|
+
return BigInt(value);
|
|
164
|
+
}
|
|
165
|
+
if (ns.isBigDecimalSchema() && value != void 0) {
|
|
166
|
+
if (value instanceof NumericValue) {
|
|
167
|
+
return value;
|
|
168
|
+
}
|
|
169
|
+
const untyped = value;
|
|
170
|
+
if (untyped.type === "bigDecimal" && "string" in untyped) {
|
|
171
|
+
return new NumericValue(untyped.string, untyped.type);
|
|
172
|
+
}
|
|
173
|
+
return new NumericValue(String(value), "bigDecimal");
|
|
174
|
+
}
|
|
175
|
+
if (ns.isNumericSchema() && typeof value === "string") {
|
|
176
|
+
switch (value) {
|
|
177
|
+
case "Infinity":
|
|
178
|
+
return Infinity;
|
|
179
|
+
case "-Infinity":
|
|
180
|
+
return -Infinity;
|
|
181
|
+
case "NaN":
|
|
182
|
+
return NaN;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (ns.isDocumentSchema()) {
|
|
186
|
+
if (isObject) {
|
|
187
|
+
const out = Array.isArray(value) ? [] : {};
|
|
188
|
+
for (const [k, v] of Object.entries(value)) {
|
|
189
|
+
if (v instanceof NumericValue) {
|
|
190
|
+
out[k] = v;
|
|
191
|
+
} else {
|
|
192
|
+
out[k] = this._read(ns, v);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return out;
|
|
196
|
+
} else {
|
|
197
|
+
return structuredClone(value);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return value;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
var NUMERIC_CONTROL_CHAR = String.fromCharCode(925);
|
|
204
|
+
var JsonReplacer = class {
|
|
205
|
+
values = /* @__PURE__ */ new Map();
|
|
206
|
+
counter = 0;
|
|
207
|
+
stage = 0;
|
|
208
|
+
createReplacer() {
|
|
209
|
+
if (this.stage === 1) {
|
|
210
|
+
throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");
|
|
211
|
+
}
|
|
212
|
+
if (this.stage === 2) {
|
|
213
|
+
throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
|
|
214
|
+
}
|
|
215
|
+
this.stage = 1;
|
|
216
|
+
return (key, value) => {
|
|
217
|
+
if (value instanceof NumericValue) {
|
|
218
|
+
const v = `${NUMERIC_CONTROL_CHAR + "nv" + this.counter++}_` + value.string;
|
|
219
|
+
this.values.set(`"${v}"`, value.string);
|
|
220
|
+
return v;
|
|
221
|
+
}
|
|
222
|
+
if (typeof value === "bigint") {
|
|
223
|
+
const s = value.toString();
|
|
224
|
+
const v = `${NUMERIC_CONTROL_CHAR + "b" + this.counter++}_` + s;
|
|
225
|
+
this.values.set(`"${v}"`, s);
|
|
226
|
+
return v;
|
|
227
|
+
}
|
|
228
|
+
return value;
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
replaceInJson(json) {
|
|
232
|
+
if (this.stage === 0) {
|
|
233
|
+
throw new Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");
|
|
234
|
+
}
|
|
235
|
+
if (this.stage === 2) {
|
|
236
|
+
throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
|
|
237
|
+
}
|
|
238
|
+
this.stage = 2;
|
|
239
|
+
if (this.counter === 0) {
|
|
240
|
+
return json;
|
|
241
|
+
}
|
|
242
|
+
for (const [key, value] of this.values) {
|
|
243
|
+
json = json.replace(key, value);
|
|
244
|
+
}
|
|
245
|
+
return json;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
var JsonShapeSerializer = class extends SerdeContextConfig {
|
|
249
|
+
settings;
|
|
250
|
+
buffer;
|
|
251
|
+
rootSchema;
|
|
252
|
+
constructor(settings) {
|
|
253
|
+
super();
|
|
254
|
+
this.settings = settings;
|
|
255
|
+
}
|
|
256
|
+
write(schema, value) {
|
|
257
|
+
this.rootSchema = NormalizedSchema.of(schema);
|
|
258
|
+
this.buffer = this._write(this.rootSchema, value);
|
|
259
|
+
}
|
|
260
|
+
writeDiscriminatedDocument(schema, value) {
|
|
261
|
+
this.write(schema, value);
|
|
262
|
+
if (typeof this.buffer === "object") {
|
|
263
|
+
this.buffer.__type = NormalizedSchema.of(schema).getName(true);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
flush() {
|
|
267
|
+
const { rootSchema } = this;
|
|
268
|
+
this.rootSchema = void 0;
|
|
269
|
+
if (rootSchema?.isStructSchema() || rootSchema?.isDocumentSchema()) {
|
|
270
|
+
const replacer = new JsonReplacer();
|
|
271
|
+
return replacer.replaceInJson(JSON.stringify(this.buffer, replacer.createReplacer(), 0));
|
|
272
|
+
}
|
|
273
|
+
return this.buffer;
|
|
274
|
+
}
|
|
275
|
+
_write(schema, value, container) {
|
|
276
|
+
const isObject = value !== null && typeof value === "object";
|
|
277
|
+
const ns = NormalizedSchema.of(schema);
|
|
278
|
+
if (ns.isListSchema() && Array.isArray(value)) {
|
|
279
|
+
const listMember = ns.getValueSchema();
|
|
280
|
+
const out = [];
|
|
281
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
282
|
+
for (const item of value) {
|
|
283
|
+
if (sparse || item != null) {
|
|
284
|
+
out.push(this._write(listMember, item));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return out;
|
|
288
|
+
} else if (ns.isMapSchema() && isObject) {
|
|
289
|
+
const mapMember = ns.getValueSchema();
|
|
290
|
+
const out = {};
|
|
291
|
+
const sparse = !!ns.getMergedTraits().sparse;
|
|
292
|
+
for (const [_k, _v] of Object.entries(value)) {
|
|
293
|
+
if (sparse || _v != null) {
|
|
294
|
+
out[_k] = this._write(mapMember, _v);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return out;
|
|
298
|
+
} else if (ns.isStructSchema() && isObject) {
|
|
299
|
+
const out = {};
|
|
300
|
+
for (const [memberName, memberSchema] of serializingStructIterator(ns, value)) {
|
|
301
|
+
const serializableValue = this._write(memberSchema, value[memberName], ns);
|
|
302
|
+
if (serializableValue !== void 0) {
|
|
303
|
+
const targetKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
|
|
304
|
+
out[targetKey] = serializableValue;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return out;
|
|
308
|
+
}
|
|
309
|
+
if (value === null && container?.isStructSchema()) {
|
|
310
|
+
return void 0;
|
|
311
|
+
}
|
|
312
|
+
if (ns.isBlobSchema() && (value instanceof Uint8Array || typeof value === "string") || ns.isDocumentSchema() && value instanceof Uint8Array) {
|
|
313
|
+
if (ns === this.rootSchema) {
|
|
314
|
+
return value;
|
|
315
|
+
}
|
|
316
|
+
return (this.serdeContext?.base64Encoder ?? toBase64)(value);
|
|
317
|
+
}
|
|
318
|
+
if ((ns.isTimestampSchema() || ns.isDocumentSchema()) && value instanceof Date) {
|
|
319
|
+
const format = determineTimestampFormat(ns, this.settings);
|
|
320
|
+
switch (format) {
|
|
321
|
+
case 5:
|
|
322
|
+
return value.toISOString().replace(".000Z", "Z");
|
|
323
|
+
case 6:
|
|
324
|
+
return dateToUtcString(value);
|
|
325
|
+
case 7:
|
|
326
|
+
return value.getTime() / 1e3;
|
|
327
|
+
default:
|
|
328
|
+
console.warn("Missing timestamp format, using epoch seconds", value);
|
|
329
|
+
return value.getTime() / 1e3;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (ns.isNumericSchema() && typeof value === "number") {
|
|
333
|
+
if (Math.abs(value) === Infinity || isNaN(value)) {
|
|
334
|
+
return String(value);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (ns.isStringSchema()) {
|
|
338
|
+
if (typeof value === "undefined" && ns.isIdempotencyToken()) {
|
|
339
|
+
return v4();
|
|
340
|
+
}
|
|
341
|
+
const mediaType = ns.getMergedTraits().mediaType;
|
|
342
|
+
if (value != null && mediaType) {
|
|
343
|
+
const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
|
|
344
|
+
if (isJson) {
|
|
345
|
+
return LazyJsonString.from(value);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
if (ns.isDocumentSchema()) {
|
|
350
|
+
if (isObject) {
|
|
351
|
+
const out = Array.isArray(value) ? [] : {};
|
|
352
|
+
for (const [k, v] of Object.entries(value)) {
|
|
353
|
+
if (v instanceof NumericValue) {
|
|
354
|
+
out[k] = v;
|
|
355
|
+
} else {
|
|
356
|
+
out[k] = this._write(ns, v);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return out;
|
|
360
|
+
} else {
|
|
361
|
+
return structuredClone(value);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return value;
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
var JsonCodec = class extends SerdeContextConfig {
|
|
368
|
+
settings;
|
|
369
|
+
constructor(settings) {
|
|
370
|
+
super();
|
|
371
|
+
this.settings = settings;
|
|
372
|
+
}
|
|
373
|
+
createSerializer() {
|
|
374
|
+
const serializer = new JsonShapeSerializer(this.settings);
|
|
375
|
+
serializer.setSerdeContext(this.serdeContext);
|
|
376
|
+
return serializer;
|
|
377
|
+
}
|
|
378
|
+
createDeserializer() {
|
|
379
|
+
const deserializer = new JsonShapeDeserializer(this.settings);
|
|
380
|
+
deserializer.setSerdeContext(this.serdeContext);
|
|
381
|
+
return deserializer;
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
var AwsRestJsonProtocol = class extends HttpBindingProtocol {
|
|
385
|
+
serializer;
|
|
386
|
+
deserializer;
|
|
387
|
+
codec;
|
|
388
|
+
mixin = new ProtocolLib();
|
|
389
|
+
constructor({ defaultNamespace }) {
|
|
390
|
+
super({
|
|
391
|
+
defaultNamespace
|
|
392
|
+
});
|
|
393
|
+
const settings = {
|
|
394
|
+
timestampFormat: {
|
|
395
|
+
useTrait: true,
|
|
396
|
+
default: 7
|
|
397
|
+
},
|
|
398
|
+
httpBindings: true,
|
|
399
|
+
jsonName: true
|
|
400
|
+
};
|
|
401
|
+
this.codec = new JsonCodec(settings);
|
|
402
|
+
this.serializer = new HttpInterceptingShapeSerializer(this.codec.createSerializer(), settings);
|
|
403
|
+
this.deserializer = new HttpInterceptingShapeDeserializer(this.codec.createDeserializer(), settings);
|
|
404
|
+
}
|
|
405
|
+
getShapeId() {
|
|
406
|
+
return "aws.protocols#restJson1";
|
|
407
|
+
}
|
|
408
|
+
getPayloadCodec() {
|
|
409
|
+
return this.codec;
|
|
410
|
+
}
|
|
411
|
+
setSerdeContext(serdeContext) {
|
|
412
|
+
this.codec.setSerdeContext(serdeContext);
|
|
413
|
+
super.setSerdeContext(serdeContext);
|
|
414
|
+
}
|
|
415
|
+
async serializeRequest(operationSchema, input, context) {
|
|
416
|
+
const request = await super.serializeRequest(operationSchema, input, context);
|
|
417
|
+
const inputSchema = NormalizedSchema.of(operationSchema.input);
|
|
418
|
+
if (!request.headers["content-type"]) {
|
|
419
|
+
const contentType = this.mixin.resolveRestContentType(this.getDefaultContentType(), inputSchema);
|
|
420
|
+
if (contentType) {
|
|
421
|
+
request.headers["content-type"] = contentType;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
if (request.body == null && request.headers["content-type"] === this.getDefaultContentType()) {
|
|
425
|
+
request.body = "{}";
|
|
426
|
+
}
|
|
427
|
+
return request;
|
|
428
|
+
}
|
|
429
|
+
async deserializeResponse(operationSchema, context, response) {
|
|
430
|
+
const output = await super.deserializeResponse(operationSchema, context, response);
|
|
431
|
+
const outputSchema = NormalizedSchema.of(operationSchema.output);
|
|
432
|
+
for (const [name, member] of outputSchema.structIterator()) {
|
|
433
|
+
if (member.getMemberTraits().httpPayload && !(name in output)) {
|
|
434
|
+
output[name] = null;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return output;
|
|
438
|
+
}
|
|
439
|
+
async handleError(operationSchema, context, response, dataObject, metadata) {
|
|
440
|
+
const errorIdentifier = loadRestJsonErrorCode(response, dataObject) ?? "Unknown";
|
|
441
|
+
const { errorSchema, errorMetadata } = await this.mixin.getErrorSchemaOrThrowBaseException(errorIdentifier, this.options.defaultNamespace, response, dataObject, metadata);
|
|
442
|
+
const ns = NormalizedSchema.of(errorSchema);
|
|
443
|
+
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
|
444
|
+
const ErrorCtor = TypeRegistry.for(errorSchema[1]).getErrorCtor(errorSchema) ?? Error;
|
|
445
|
+
const exception = new ErrorCtor(message);
|
|
446
|
+
await this.deserializeHttpMessage(errorSchema, context, response, dataObject);
|
|
447
|
+
const output = {};
|
|
448
|
+
for (const [name, member] of ns.structIterator()) {
|
|
449
|
+
const target = member.getMergedTraits().jsonName ?? name;
|
|
450
|
+
output[name] = this.codec.createDeserializer().readObject(member, dataObject[target]);
|
|
451
|
+
}
|
|
452
|
+
throw this.mixin.decorateServiceException(Object.assign(exception, errorMetadata, {
|
|
453
|
+
$fault: ns.getMergedTraits().error,
|
|
454
|
+
message
|
|
455
|
+
}, output), dataObject);
|
|
456
|
+
}
|
|
457
|
+
getDefaultContentType() {
|
|
458
|
+
return "application/json";
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
export {
|
|
463
|
+
AwsRestJsonProtocol
|
|
464
|
+
};
|