@alt-stack/zod-error 0.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.
@@ -0,0 +1,22 @@
1
+
2
+ > @alt-stack/zod-error@0.0.1 build /home/runner/work/alt-stack/alt-stack/packages/zod-error
3
+ > tsup
4
+
5
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.5.0
8
+ CLI Using tsup config: /home/runner/work/alt-stack/alt-stack/packages/zod-error/tsup.config.ts
9
+ CLI Target: es2022
10
+ CLI Cleaning output folder
11
+ ESM Build start
12
+ CJS Build start
13
+ ESM dist/index.mjs 622.00 B
14
+ ESM dist/index.mjs.map 1.56 KB
15
+ ESM ⚡️ Build success in 16ms
16
+ CJS dist/index.js 1.68 KB
17
+ CJS dist/index.js.map 1.78 KB
18
+ CJS ⚡️ Build success in 16ms
19
+ DTS Build start
20
+ DTS ⚡️ Build success in 822ms
21
+ DTS dist/index.d.mts 659.00 B
22
+ DTS dist/index.d.ts 659.00 B
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Anthony Altieri
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ import { ZodError } from 'zod';
2
+
3
+ interface StructuredLogError {
4
+ type: "ZodValidationError";
5
+ message: string;
6
+ issueCount: number;
7
+ issues: Array<{
8
+ path: string;
9
+ message: string;
10
+ code: string;
11
+ }>;
12
+ input?: unknown;
13
+ }
14
+ /**
15
+ * Formats ZodError into a human-readable string
16
+ */
17
+ declare function zodErrorToString(error: ZodError): string;
18
+ /**
19
+ * Formats ZodError for structured logging systems
20
+ * Includes optional input data for debugging
21
+ */
22
+ declare function zodErrorToStructuredLog(error: ZodError, input?: unknown): StructuredLogError;
23
+
24
+ export { type StructuredLogError, zodErrorToString, zodErrorToStructuredLog };
@@ -0,0 +1,24 @@
1
+ import { ZodError } from 'zod';
2
+
3
+ interface StructuredLogError {
4
+ type: "ZodValidationError";
5
+ message: string;
6
+ issueCount: number;
7
+ issues: Array<{
8
+ path: string;
9
+ message: string;
10
+ code: string;
11
+ }>;
12
+ input?: unknown;
13
+ }
14
+ /**
15
+ * Formats ZodError into a human-readable string
16
+ */
17
+ declare function zodErrorToString(error: ZodError): string;
18
+ /**
19
+ * Formats ZodError for structured logging systems
20
+ * Includes optional input data for debugging
21
+ */
22
+ declare function zodErrorToStructuredLog(error: ZodError, input?: unknown): StructuredLogError;
23
+
24
+ export { type StructuredLogError, zodErrorToString, zodErrorToStructuredLog };
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ zodErrorToString: () => zodErrorToString,
24
+ zodErrorToStructuredLog: () => zodErrorToStructuredLog
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/structured-log.ts
29
+ function zodErrorToString(error) {
30
+ return error.issues.map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`).join("; ");
31
+ }
32
+ function zodErrorToStructuredLog(error, input) {
33
+ return {
34
+ type: "ZodValidationError",
35
+ message: zodErrorToString(error),
36
+ issueCount: error.issues.length,
37
+ issues: error.issues.map((issue) => ({
38
+ path: issue.path.join(".") || "(root)",
39
+ message: issue.message,
40
+ code: issue.code
41
+ })),
42
+ ...input !== void 0 && { input }
43
+ };
44
+ }
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ zodErrorToString,
48
+ zodErrorToStructuredLog
49
+ });
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/structured-log.ts"],"sourcesContent":["export type { StructuredLogError } from \"./structured-log.js\";\nexport { zodErrorToString, zodErrorToStructuredLog } from \"./structured-log.js\";\n","import type { ZodError } from \"zod\";\n\nexport interface StructuredLogError {\n type: \"ZodValidationError\";\n message: string;\n issueCount: number;\n issues: Array<{\n path: string;\n message: string;\n code: string;\n }>;\n input?: unknown;\n}\n\n/**\n * Formats ZodError into a human-readable string\n */\nexport function zodErrorToString(error: ZodError): string {\n return error.issues\n .map((issue) => `${issue.path.join(\".\") || \"(root)\"}: ${issue.message}`)\n .join(\"; \");\n}\n\n/**\n * Formats ZodError for structured logging systems\n * Includes optional input data for debugging\n */\nexport function zodErrorToStructuredLog(error: ZodError, input?: unknown): StructuredLogError {\n return {\n type: \"ZodValidationError\",\n message: zodErrorToString(error),\n issueCount: error.issues.length,\n issues: error.issues.map((issue) => ({\n path: issue.path.join(\".\") || \"(root)\",\n message: issue.message,\n code: issue.code,\n })),\n ...(input !== undefined && { input }),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,SAAS,iBAAiB,OAAyB;AACxD,SAAO,MAAM,OACV,IAAI,CAAC,UAAU,GAAG,MAAM,KAAK,KAAK,GAAG,KAAK,QAAQ,KAAK,MAAM,OAAO,EAAE,EACtE,KAAK,IAAI;AACd;AAMO,SAAS,wBAAwB,OAAiB,OAAqC;AAC5F,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,iBAAiB,KAAK;AAAA,IAC/B,YAAY,MAAM,OAAO;AAAA,IACzB,QAAQ,MAAM,OAAO,IAAI,CAAC,WAAW;AAAA,MACnC,MAAM,MAAM,KAAK,KAAK,GAAG,KAAK;AAAA,MAC9B,SAAS,MAAM;AAAA,MACf,MAAM,MAAM;AAAA,IACd,EAAE;AAAA,IACF,GAAI,UAAU,UAAa,EAAE,MAAM;AAAA,EACrC;AACF;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,22 @@
1
+ // src/structured-log.ts
2
+ function zodErrorToString(error) {
3
+ return error.issues.map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`).join("; ");
4
+ }
5
+ function zodErrorToStructuredLog(error, input) {
6
+ return {
7
+ type: "ZodValidationError",
8
+ message: zodErrorToString(error),
9
+ issueCount: error.issues.length,
10
+ issues: error.issues.map((issue) => ({
11
+ path: issue.path.join(".") || "(root)",
12
+ message: issue.message,
13
+ code: issue.code
14
+ })),
15
+ ...input !== void 0 && { input }
16
+ };
17
+ }
18
+ export {
19
+ zodErrorToString,
20
+ zodErrorToStructuredLog
21
+ };
22
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/structured-log.ts"],"sourcesContent":["import type { ZodError } from \"zod\";\n\nexport interface StructuredLogError {\n type: \"ZodValidationError\";\n message: string;\n issueCount: number;\n issues: Array<{\n path: string;\n message: string;\n code: string;\n }>;\n input?: unknown;\n}\n\n/**\n * Formats ZodError into a human-readable string\n */\nexport function zodErrorToString(error: ZodError): string {\n return error.issues\n .map((issue) => `${issue.path.join(\".\") || \"(root)\"}: ${issue.message}`)\n .join(\"; \");\n}\n\n/**\n * Formats ZodError for structured logging systems\n * Includes optional input data for debugging\n */\nexport function zodErrorToStructuredLog(error: ZodError, input?: unknown): StructuredLogError {\n return {\n type: \"ZodValidationError\",\n message: zodErrorToString(error),\n issueCount: error.issues.length,\n issues: error.issues.map((issue) => ({\n path: issue.path.join(\".\") || \"(root)\",\n message: issue.message,\n code: issue.code,\n })),\n ...(input !== undefined && { input }),\n };\n}\n"],"mappings":";AAiBO,SAAS,iBAAiB,OAAyB;AACxD,SAAO,MAAM,OACV,IAAI,CAAC,UAAU,GAAG,MAAM,KAAK,KAAK,GAAG,KAAK,QAAQ,KAAK,MAAM,OAAO,EAAE,EACtE,KAAK,IAAI;AACd;AAMO,SAAS,wBAAwB,OAAiB,OAAqC;AAC5F,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,iBAAiB,KAAK;AAAA,IAC/B,YAAY,MAAM,OAAO;AAAA,IACzB,QAAQ,MAAM,OAAO,IAAI,CAAC,WAAW;AAAA,MACnC,MAAM,MAAM,KAAK,KAAK,GAAG,KAAK;AAAA,MAC9B,SAAS,MAAM;AAAA,MACf,MAAM,MAAM;AAAA,IACd,EAAE;AAAA,IACF,GAAI,UAAU,UAAa,EAAE,MAAM;AAAA,EACrC;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@alt-stack/zod-error",
3
+ "version": "0.0.1",
4
+ "description": "Utilities for formatting ZodError for structured logging",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "keywords": [
16
+ "zod",
17
+ "error",
18
+ "validation",
19
+ "logging",
20
+ "structured-logging"
21
+ ],
22
+ "author": "",
23
+ "license": "MIT",
24
+ "peerDependencies": {
25
+ "zod": "^4.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "tsup": "^8.0.0",
29
+ "typescript": "^5.9.2",
30
+ "vitest": "^4.0.3",
31
+ "zod": "^4.0.0"
32
+ },
33
+ "scripts": {
34
+ "build": "tsup",
35
+ "test": "vitest",
36
+ "check-types": "tsc --noEmit"
37
+ }
38
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export type { StructuredLogError } from "./structured-log.js";
2
+ export { zodErrorToString, zodErrorToStructuredLog } from "./structured-log.js";
@@ -0,0 +1,40 @@
1
+ import type { ZodError } from "zod";
2
+
3
+ export interface StructuredLogError {
4
+ type: "ZodValidationError";
5
+ message: string;
6
+ issueCount: number;
7
+ issues: Array<{
8
+ path: string;
9
+ message: string;
10
+ code: string;
11
+ }>;
12
+ input?: unknown;
13
+ }
14
+
15
+ /**
16
+ * Formats ZodError into a human-readable string
17
+ */
18
+ export function zodErrorToString(error: ZodError): string {
19
+ return error.issues
20
+ .map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`)
21
+ .join("; ");
22
+ }
23
+
24
+ /**
25
+ * Formats ZodError for structured logging systems
26
+ * Includes optional input data for debugging
27
+ */
28
+ export function zodErrorToStructuredLog(error: ZodError, input?: unknown): StructuredLogError {
29
+ return {
30
+ type: "ZodValidationError",
31
+ message: zodErrorToString(error),
32
+ issueCount: error.issues.length,
33
+ issues: error.issues.map((issue) => ({
34
+ path: issue.path.join(".") || "(root)",
35
+ message: issue.message,
36
+ code: issue.code,
37
+ })),
38
+ ...(input !== undefined && { input }),
39
+ };
40
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "../typescript-config/base.json",
4
+ "compilerOptions": {
5
+ "outDir": "./dist",
6
+ "rootDir": "./src"
7
+ },
8
+ "include": ["src/**/*"],
9
+ "exclude": ["node_modules", "dist"]
10
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig({
4
+ entry: ["src/index.ts"],
5
+ format: ["esm", "cjs"],
6
+ dts: true,
7
+ splitting: false,
8
+ sourcemap: true,
9
+ clean: true,
10
+ });