Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.6 KiB
Text
42 lines
1.6 KiB
Text
import { NormalizedSchema } from "@smithy/core/schema";
|
|
import { fromUtf8, toUtf8 } from "@smithy/util-utf8";
|
|
import { SerdeContext } from "../SerdeContext";
|
|
import { FromStringShapeDeserializer } from "./FromStringShapeDeserializer";
|
|
export class HttpInterceptingShapeDeserializer extends SerdeContext {
|
|
codecDeserializer;
|
|
stringDeserializer;
|
|
constructor(codecDeserializer, codecSettings) {
|
|
super();
|
|
this.codecDeserializer = codecDeserializer;
|
|
this.stringDeserializer = new FromStringShapeDeserializer(codecSettings);
|
|
}
|
|
setSerdeContext(serdeContext) {
|
|
this.stringDeserializer.setSerdeContext(serdeContext);
|
|
this.codecDeserializer.setSerdeContext(serdeContext);
|
|
this.serdeContext = serdeContext;
|
|
}
|
|
read(schema, data) {
|
|
const ns = NormalizedSchema.of(schema);
|
|
const traits = ns.getMergedTraits();
|
|
const toString = this.serdeContext?.utf8Encoder ?? toUtf8;
|
|
if (traits.httpHeader || traits.httpResponseCode) {
|
|
return this.stringDeserializer.read(ns, toString(data));
|
|
}
|
|
if (traits.httpPayload) {
|
|
if (ns.isBlobSchema()) {
|
|
const toBytes = this.serdeContext?.utf8Decoder ?? fromUtf8;
|
|
if (typeof data === "string") {
|
|
return toBytes(data);
|
|
}
|
|
return data;
|
|
}
|
|
else if (ns.isStringSchema()) {
|
|
if ("byteLength" in data) {
|
|
return toString(data);
|
|
}
|
|
return data;
|
|
}
|
|
}
|
|
return this.codecDeserializer.read(ns, data);
|
|
}
|
|
}
|