@composio/json-schema-to-zod 0.2.1 → 0.2.2

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.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { ZodTypeAny, z } from "zod/v3";
2
-
3
2
  //#region ../../../node_modules/.pnpm/@types+json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts
4
3
  // ==================================================================================================
5
4
  // JSON Schema Draft 07
@@ -11,13 +10,13 @@ import { ZodTypeAny, z } from "zod/v3";
11
10
  * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
12
11
  */
13
12
  type JSONSchema7TypeName = "string" //
14
- | "number" | "integer" | "boolean" | "object" | "array" | "null";
13
+ | "number" | "integer" | "boolean" | "object" | "array" | "null";
15
14
  /**
16
15
  * Primitive type
17
16
  * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
18
17
  */
19
18
  type JSONSchema7Type = string //
20
- | number | boolean | JSONSchema7Object | JSONSchema7Array | null;
19
+ | number | boolean | JSONSchema7Object | JSONSchema7Array | null;
21
20
  // Workaround for infinite type recursion
22
21
  interface JSONSchema7Object {
23
22
  [key: string]: JSONSchema7Type;
@@ -144,7 +143,29 @@ type Serializable = {
144
143
  [key: string]: Serializable;
145
144
  } | Serializable[] | string | number | boolean | null;
146
145
  type JsonSchema = JsonSchemaObject | boolean;
147
- type JsonSchemaObject = JSONSchema7;
146
+ type JsonSchemaDefinitions = Record<string, JsonSchema>;
147
+ interface JsonSchemaObject extends Omit<JSONSchema7, '$defs' | 'items' | 'additionalItems' | 'contains' | 'properties' | 'patternProperties' | 'additionalProperties' | 'dependencies' | 'propertyNames' | 'if' | 'then' | 'else' | 'allOf' | 'anyOf' | 'oneOf' | 'not' | 'definitions'> {
148
+ min?: number;
149
+ max?: number;
150
+ example?: Serializable;
151
+ $defs?: JsonSchemaDefinitions;
152
+ definitions?: JsonSchemaDefinitions;
153
+ items?: JsonSchema | JsonSchema[];
154
+ additionalItems?: JsonSchema;
155
+ contains?: JsonSchema;
156
+ properties?: JsonSchemaDefinitions;
157
+ patternProperties?: JsonSchemaDefinitions;
158
+ additionalProperties?: JsonSchema;
159
+ dependencies?: Record<string, JsonSchema | string[]>;
160
+ propertyNames?: JsonSchema;
161
+ if?: JsonSchema;
162
+ then?: JsonSchema;
163
+ else?: JsonSchema;
164
+ allOf?: JsonSchema[];
165
+ anyOf?: JsonSchema[];
166
+ oneOf?: JsonSchema[];
167
+ not?: JsonSchema;
168
+ }
148
169
  type ParserSelector = (schema: JsonSchemaObject, refs: Refs) => ZodTypeAny;
149
170
  type ParserOverride = (schema: JsonSchemaObject, refs: Refs) => ZodTypeAny | undefined;
150
171
  type JsonSchemaToZodOptions = {
package/dist/index.mjs CHANGED
@@ -486,7 +486,7 @@ const addDescribes = (jsonSchema, zodSchema) => {
486
486
  description = description ? `${description}\n${exampleText}` : exampleText;
487
487
  } else if (jsonSchema.examples !== void 0 && Array.isArray(jsonSchema.examples)) {
488
488
  const examples = jsonSchema.examples;
489
- if (examples && examples.length && examples.length > 0) {
489
+ if (examples.length > 0) {
490
490
  const exampleText = examples.length === 1 ? `Example: ${JSON.stringify(examples[0])}` : `Examples:\n${examples.map((ex) => ` ${JSON.stringify(ex)}`).join("\n")}`;
491
491
  description = description ? `${description}\n${exampleText}` : exampleText;
492
492
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composio/json-schema-to-zod",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "",
5
5
  "main": "dist/index.mjs",
6
6
  "type": "module",
@@ -34,9 +34,9 @@
34
34
  "license": "ISC",
35
35
  "devDependencies": {
36
36
  "@types/json-schema": "^7.0.15",
37
- "@types/node": "^26.1.0",
38
- "tsdown": "^0.22.3",
39
- "typescript": "^6.0.3",
37
+ "@types/node": "^26.1.2",
38
+ "tsdown": "^0.22.14",
39
+ "typescript": "^7.0.2",
40
40
  "vitest": "^4.1.10",
41
41
  "zod": "^4.4.3"
42
42
  },
@@ -47,12 +47,9 @@
47
47
  "clean": "git clean -xdf node_modules",
48
48
  "build": "tsdown",
49
49
  "test": "vitest run",
50
- "typecheck:src": "pnpm exec tsgo --noEmit -p ./tsconfig.src.json",
51
- "typecheck:test": "pnpm exec tsgo --noEmit -p ./tsconfig.test.json",
52
- "typecheck": "pnpm run typecheck:src && pnpm run typecheck:test",
53
- "typecheck:src:tsc": "tsc --noEmit -p ./tsconfig.src.json",
54
- "typecheck:test:tsc": "tsc --noEmit -p ./tsconfig.test.json",
55
- "typecheck:tsc": "pnpm run typecheck:src:tsc && pnpm run typecheck:test:tsc"
50
+ "typecheck:src": "tsc --noEmit -p ./tsconfig.src.json",
51
+ "typecheck:test": "tsc --noEmit -p ./tsconfig.test.json",
52
+ "typecheck": "pnpm run typecheck:src && pnpm run typecheck:test"
56
53
  },
57
54
  "types": "dist/index.d.mts"
58
55
  }