Rocky_Mountain_Vending/.pnpm-store/v10/files/3c/7c3f60bdbe0e0f16b8944758b38015e5bab0340cb7cef68aac2c826573f427fd599a8124e5174cab9fb711996d5adf4084962029175fade3427ac1a3ad0357
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
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>
2026-02-12 16:22:15 -07:00

46 lines
1.5 KiB
Text

import { parseXML } from "@aws-sdk/xml-builder";
import { getValueFromTextNode } from "@smithy/smithy-client";
import { collectBodyString } from "../common";
export const parseXmlBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
if (encoded.length) {
let parsedObj;
try {
parsedObj = parseXML(encoded);
}
catch (e) {
if (e && typeof e === "object") {
Object.defineProperty(e, "$responseBodyText", {
value: encoded,
});
}
throw e;
}
const textNodeName = "#text";
const key = Object.keys(parsedObj)[0];
const parsedObjToReturn = parsedObj[key];
if (parsedObjToReturn[textNodeName]) {
parsedObjToReturn[key] = parsedObjToReturn[textNodeName];
delete parsedObjToReturn[textNodeName];
}
return getValueFromTextNode(parsedObjToReturn);
}
return {};
});
export const parseXmlErrorBody = async (errorBody, context) => {
const value = await parseXmlBody(errorBody, context);
if (value.Error) {
value.Error.message = value.Error.message ?? value.Error.Message;
}
return value;
};
export const loadRestXmlErrorCode = (output, data) => {
if (data?.Error?.Code !== undefined) {
return data.Error.Code;
}
if (data?.Code !== undefined) {
return data.Code;
}
if (output.statusCode == 404) {
return "NotFound";
}
};