zlient 1.0.4 → 1.0.6

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.
@@ -1,5 +1,44 @@
1
1
  import { z } from 'zod';
2
2
  import { SafeParseResult } from './types';
3
+ /**
4
+ * Safely parse data with a Zod schema without throwing.
5
+ * Returns a result object with success status and data or error.
6
+ *
7
+ * @param schema - Zod schema to validate against
8
+ * @param data - Data to validate
9
+ * @returns Result object with success flag and data/error
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const result = safeParse(UserSchema, userData);
14
+ * if (result.success) {
15
+ * console.log(result.data);
16
+ * } else {
17
+ * console.error(result.error);
18
+ * }
19
+ * ```
20
+ */
3
21
  export declare function safeParse<T>(schema: z.ZodTypeAny, data: unknown): SafeParseResult<T>;
22
+ /**
23
+ * Parse data with a Zod schema, throwing an ApiError on validation failure.
24
+ * Use this when you want to fail fast on invalid data.
25
+ *
26
+ * @param schema - Zod schema to validate against
27
+ * @param data - Data to validate
28
+ * @returns Validated and typed data
29
+ * @throws {ApiError} If validation fails
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * try {
34
+ * const user = parseOrThrow(UserSchema, userData);
35
+ * console.log(user);
36
+ * } catch (error) {
37
+ * if (error instanceof ApiError && error.zodError) {
38
+ * console.error('Validation failed:', error.zodError.issues);
39
+ * }
40
+ * }
41
+ * ```
42
+ */
4
43
  export declare function parseOrThrow<T>(schema: z.ZodTypeAny, data: unknown): T;
5
44
  //# sourceMappingURL=validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../lib/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAY,eAAe,EAAE,MAAM,SAAS,CAAC;AAEpD,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,eAAe,CAAC,CAAC,CAAC,CAIpF;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,CAAC,CAMtE"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../lib/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAY,eAAe,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,eAAe,CAAC,CAAC,CAAC,CAIpF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,CAAC,CAMtE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zlient",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "A type-safe HTTP client framework with Zod validation for building robust API clients",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",