@composio/json-schema-to-zod 0.1.19 → 0.1.20

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.
package/dist/index.d.cts CHANGED
@@ -1,27 +1,47 @@
1
- import { ZodTypeAny, z } from 'zod/v3';
2
- import { JSONSchema7 } from 'json-schema';
1
+ import { ZodTypeAny, z } from "zod/v3";
2
+ import { JSONSchema7 } from "json-schema";
3
3
 
4
+ //#region src/types.d.ts
4
5
  type Serializable = {
5
- [key: string]: Serializable;
6
+ [key: string]: Serializable;
6
7
  } | Serializable[] | string | number | boolean | null;
7
8
  type JsonSchema = JsonSchemaObject | boolean;
8
9
  type JsonSchemaObject = JSONSchema7;
9
10
  type ParserSelector = (schema: JsonSchemaObject, refs: Refs) => ZodTypeAny;
10
11
  type ParserOverride = (schema: JsonSchemaObject, refs: Refs) => ZodTypeAny | undefined;
11
12
  type JsonSchemaToZodOptions = {
12
- withoutDefaults?: boolean;
13
- withoutDescribes?: boolean;
14
- parserOverride?: ParserOverride;
15
- depth?: number;
13
+ withoutDefaults?: boolean;
14
+ withoutDescribes?: boolean;
15
+ parserOverride?: ParserOverride;
16
+ depth?: number;
16
17
  };
17
18
  type Refs = JsonSchemaToZodOptions & {
18
- path: Array<string | number>;
19
- seen: Map<object | boolean, {
20
- n: number;
21
- r: ZodTypeAny | undefined;
22
- }>;
19
+ path: Array<string | number>;
20
+ seen: Map<object | boolean, {
21
+ n: number;
22
+ r: ZodTypeAny | undefined;
23
+ }>;
23
24
  };
24
-
25
+ //#endregion
26
+ //#region src/json-schema-to-zod.d.ts
25
27
  declare const jsonSchemaToZod: (schema: JsonSchema, options?: JsonSchemaToZodOptions) => z.ZodType;
26
-
27
- export { type JsonSchema, type JsonSchemaObject, type JsonSchemaToZodOptions, type ParserOverride, type ParserSelector, type Refs, type Serializable, jsonSchemaToZod };
28
+ /**
29
+ * A simplified type for Zod raw shapes that avoids deep type instantiation issues.
30
+ * This is compatible with ZodRawShape but uses a simpler type signature.
31
+ */
32
+ type SimpleZodRawShape = Record<string, ZodTypeAny>;
33
+ /**
34
+ * Converts a JSON Schema object to a Zod raw shape.
35
+ * This is useful when you need the shape object (e.g., `{ name: z.string(), age: z.number() }`)
36
+ * rather than a complete ZodObject schema.
37
+ *
38
+ * This is particularly useful for APIs that expect ZodRawShape instead of ZodType,
39
+ * such as the Claude Agent SDK's `tool()` function.
40
+ *
41
+ * @param schema - The JSON Schema to convert (must be an object schema)
42
+ * @param options - Optional configuration for the conversion
43
+ * @returns A Zod raw shape object with property keys mapped to Zod types
44
+ */
45
+ declare const jsonSchemaToZodShape: (schema: JsonSchema, options?: JsonSchemaToZodOptions) => SimpleZodRawShape;
46
+ //#endregion
47
+ export { JsonSchema, JsonSchemaObject, JsonSchemaToZodOptions, ParserOverride, ParserSelector, Refs, Serializable, jsonSchemaToZod, jsonSchemaToZodShape };
@@ -0,0 +1,47 @@
1
+ import { ZodTypeAny, z } from "zod/v3";
2
+ import { JSONSchema7 } from "json-schema";
3
+
4
+ //#region src/types.d.ts
5
+ type Serializable = {
6
+ [key: string]: Serializable;
7
+ } | Serializable[] | string | number | boolean | null;
8
+ type JsonSchema = JsonSchemaObject | boolean;
9
+ type JsonSchemaObject = JSONSchema7;
10
+ type ParserSelector = (schema: JsonSchemaObject, refs: Refs) => ZodTypeAny;
11
+ type ParserOverride = (schema: JsonSchemaObject, refs: Refs) => ZodTypeAny | undefined;
12
+ type JsonSchemaToZodOptions = {
13
+ withoutDefaults?: boolean;
14
+ withoutDescribes?: boolean;
15
+ parserOverride?: ParserOverride;
16
+ depth?: number;
17
+ };
18
+ type Refs = JsonSchemaToZodOptions & {
19
+ path: Array<string | number>;
20
+ seen: Map<object | boolean, {
21
+ n: number;
22
+ r: ZodTypeAny | undefined;
23
+ }>;
24
+ };
25
+ //#endregion
26
+ //#region src/json-schema-to-zod.d.ts
27
+ declare const jsonSchemaToZod: (schema: JsonSchema, options?: JsonSchemaToZodOptions) => z.ZodType;
28
+ /**
29
+ * A simplified type for Zod raw shapes that avoids deep type instantiation issues.
30
+ * This is compatible with ZodRawShape but uses a simpler type signature.
31
+ */
32
+ type SimpleZodRawShape = Record<string, ZodTypeAny>;
33
+ /**
34
+ * Converts a JSON Schema object to a Zod raw shape.
35
+ * This is useful when you need the shape object (e.g., `{ name: z.string(), age: z.number() }`)
36
+ * rather than a complete ZodObject schema.
37
+ *
38
+ * This is particularly useful for APIs that expect ZodRawShape instead of ZodType,
39
+ * such as the Claude Agent SDK's `tool()` function.
40
+ *
41
+ * @param schema - The JSON Schema to convert (must be an object schema)
42
+ * @param options - Optional configuration for the conversion
43
+ * @returns A Zod raw shape object with property keys mapped to Zod types
44
+ */
45
+ declare const jsonSchemaToZodShape: (schema: JsonSchema, options?: JsonSchemaToZodOptions) => SimpleZodRawShape;
46
+ //#endregion
47
+ export { JsonSchema, JsonSchemaObject, JsonSchemaToZodOptions, ParserOverride, ParserSelector, Refs, Serializable, jsonSchemaToZod, jsonSchemaToZodShape };