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>
34 lines
1.1 KiB
Text
34 lines
1.1 KiB
Text
import { NormalizedSchema } from "@smithy/core/schema";
|
|
const SENSITIVE_STRING = "***SensitiveInformation***";
|
|
export function schemaLogFilter(schema, data) {
|
|
if (data == null) {
|
|
return data;
|
|
}
|
|
const ns = NormalizedSchema.of(schema);
|
|
if (ns.getMergedTraits().sensitive) {
|
|
return SENSITIVE_STRING;
|
|
}
|
|
if (ns.isListSchema()) {
|
|
const isSensitive = !!ns.getValueSchema().getMergedTraits().sensitive;
|
|
if (isSensitive) {
|
|
return SENSITIVE_STRING;
|
|
}
|
|
}
|
|
else if (ns.isMapSchema()) {
|
|
const isSensitive = !!ns.getKeySchema().getMergedTraits().sensitive || !!ns.getValueSchema().getMergedTraits().sensitive;
|
|
if (isSensitive) {
|
|
return SENSITIVE_STRING;
|
|
}
|
|
}
|
|
else if (ns.isStructSchema() && typeof data === "object") {
|
|
const object = data;
|
|
const newObject = {};
|
|
for (const [member, memberNs] of ns.structIterator()) {
|
|
if (object[member] != null) {
|
|
newObject[member] = schemaLogFilter(memberNs, object[member]);
|
|
}
|
|
}
|
|
return newObject;
|
|
}
|
|
return data;
|
|
}
|