Rocky_Mountain_Vending/.pnpm-store/v10/files/92/14bbb632624cf7fd8f5842699f5c5ce69097b30a0014dbec7e0771ce855757de6ea5b5f8a6b21d4d83c4ba301bd18c92f1c8f93f1a6b2de1debc3449f5f761
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

1 line
No EOL
10 KiB
Text

{"version":3,"file":"zoderrors.js","sources":["../../../src/integrations/zoderrors.ts"],"sourcesContent":["import { defineIntegration } from '../integration';\nimport type { Event, EventHint } from '../types-hoist/event';\nimport type { IntegrationFn } from '../types-hoist/integration';\nimport { isError } from '../utils/is';\nimport { truncate } from '../utils/string';\n\ninterface ZodErrorsOptions {\n key?: string;\n /**\n * Limits the number of Zod errors inlined in each Sentry event.\n *\n * @default 10\n */\n limit?: number;\n /**\n * Save full list of Zod issues as an attachment in Sentry\n *\n * @default false\n */\n saveZodIssuesAsAttachment?: boolean;\n}\n\nconst DEFAULT_LIMIT = 10;\nconst INTEGRATION_NAME = 'ZodErrors';\n\n/**\n * Simplified ZodIssue type definition\n */\ninterface ZodIssue {\n path: (string | number)[];\n message?: string;\n expected?: unknown;\n received?: unknown;\n unionErrors?: unknown[];\n keys?: unknown[];\n invalid_literal?: unknown;\n}\n\ninterface ZodError extends Error {\n issues: ZodIssue[];\n}\n\nfunction originalExceptionIsZodError(originalException: unknown): originalException is ZodError {\n return (\n isError(originalException) &&\n originalException.name === 'ZodError' &&\n Array.isArray((originalException as ZodError).issues)\n );\n}\n\ntype SingleLevelZodIssue<T extends ZodIssue> = {\n [P in keyof T]: T[P] extends string | number | undefined\n ? T[P]\n : T[P] extends unknown[]\n ? string | undefined\n : unknown;\n};\n\n/**\n * Formats child objects or arrays to a string\n * that is preserved when sent to Sentry.\n *\n * Without this, we end up with something like this in Sentry:\n *\n * [\n * [Object],\n * [Object],\n * [Object],\n * [Object]\n * ]\n */\nexport function flattenIssue(issue: ZodIssue): SingleLevelZodIssue<ZodIssue> {\n return {\n ...issue,\n path: 'path' in issue && Array.isArray(issue.path) ? issue.path.join('.') : undefined,\n keys: 'keys' in issue ? JSON.stringify(issue.keys) : undefined,\n unionErrors: 'unionErrors' in issue ? JSON.stringify(issue.unionErrors) : undefined,\n };\n}\n\n/**\n * Takes ZodError issue path array and returns a flattened version as a string.\n * This makes it easier to display paths within a Sentry error message.\n *\n * Array indexes are normalized to reduce duplicate entries\n *\n * @param path ZodError issue path\n * @returns flattened path\n *\n * @example\n * flattenIssuePath([0, 'foo', 1, 'bar']) // -> '<array>.foo.<array>.bar'\n */\nexport function flattenIssuePath(path: Array<string | number>): string {\n return path\n .map(p => {\n if (typeof p === 'number') {\n return '<array>';\n } else {\n return p;\n }\n })\n .join('.');\n}\n\n/**\n * Zod error message is a stringified version of ZodError.issues\n * This doesn't display well in the Sentry UI. Replace it with something shorter.\n */\nexport function formatIssueMessage(zodError: ZodError): string {\n const errorKeyMap = new Set<string | number | symbol>();\n for (const iss of zodError.issues) {\n const issuePath = flattenIssuePath(iss.path);\n if (issuePath.length > 0) {\n errorKeyMap.add(issuePath);\n }\n }\n\n const errorKeys = Array.from(errorKeyMap);\n if (errorKeys.length === 0) {\n // If there are no keys, then we're likely validating the root\n // variable rather than a key within an object. This attempts\n // to extract what type it was that failed to validate.\n // For example, z.string().parse(123) would return \"string\" here.\n let rootExpectedType = 'variable';\n if (zodError.issues.length > 0) {\n const iss = zodError.issues[0];\n if (iss !== undefined && 'expected' in iss && typeof iss.expected === 'string') {\n rootExpectedType = iss.expected;\n }\n }\n return `Failed to validate ${rootExpectedType}`;\n }\n return `Failed to validate keys: ${truncate(errorKeys.join(', '), 100)}`;\n}\n\n/**\n * Applies ZodError issues to an event extra and replaces the error message\n */\nexport function applyZodErrorsToEvent(\n limit: number,\n saveZodIssuesAsAttachment: boolean = false,\n event: Event,\n hint: EventHint,\n): Event {\n if (\n !event.exception?.values ||\n !hint.originalException ||\n !originalExceptionIsZodError(hint.originalException) ||\n hint.originalException.issues.length === 0\n ) {\n return event;\n }\n\n try {\n const issuesToFlatten = saveZodIssuesAsAttachment\n ? hint.originalException.issues\n : hint.originalException.issues.slice(0, limit);\n const flattenedIssues = issuesToFlatten.map(flattenIssue);\n\n if (saveZodIssuesAsAttachment) {\n // Sometimes having the full error details can be helpful.\n // Attachments have much higher limits, so we can include the full list of issues.\n if (!Array.isArray(hint.attachments)) {\n hint.attachments = [];\n }\n hint.attachments.push({\n filename: 'zod_issues.json',\n data: JSON.stringify({\n issues: flattenedIssues,\n }),\n });\n }\n\n return {\n ...event,\n exception: {\n ...event.exception,\n values: [\n {\n ...event.exception.values[0],\n value: formatIssueMessage(hint.originalException),\n },\n ...event.exception.values.slice(1),\n ],\n },\n extra: {\n ...event.extra,\n 'zoderror.issues': flattenedIssues.slice(0, limit),\n },\n };\n } catch (e) {\n // Hopefully we never throw errors here, but record it\n // with the event just in case.\n return {\n ...event,\n extra: {\n ...event.extra,\n 'zoderrors sentry integration parse error': {\n message: 'an exception was thrown while processing ZodError within applyZodErrorsToEvent()',\n error: e instanceof Error ? `${e.name}: ${e.message}\\n${e.stack}` : 'unknown',\n },\n },\n };\n }\n}\n\nconst _zodErrorsIntegration = ((options: ZodErrorsOptions = {}) => {\n const limit = options.limit ?? DEFAULT_LIMIT;\n\n return {\n name: INTEGRATION_NAME,\n processEvent(originalEvent, hint): Event {\n const processedEvent = applyZodErrorsToEvent(limit, options.saveZodIssuesAsAttachment, originalEvent, hint);\n return processedEvent;\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Sentry integration to process Zod errors, making them easier to work with in Sentry.\n */\nexport const zodErrorsIntegration = defineIntegration(_zodErrorsIntegration);\n"],"names":["isError","truncate","defineIntegration"],"mappings":";;;;;;AAsBA,MAAM,aAAA,GAAgB,EAAE;AACxB,MAAM,gBAAA,GAA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