@composio/json-schema-to-zod 0.3.3 → 0.4.0

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,191 +1,7 @@
1
- import { ZodTypeAny, z } from "zod/v3";
2
- //#region ../../../node_modules/.pnpm/@types+json-schema@7.0.15/node_modules/@types/json-schema/index.d.ts
3
- // ==================================================================================================
4
- // JSON Schema Draft 07
5
- // ==================================================================================================
6
- // https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
7
- // --------------------------------------------------------------------------------------------------
8
- /**
9
- * Primitive type
10
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
11
- */
12
- type JSONSchema7TypeName = "string" //
13
- | "number" | "integer" | "boolean" | "object" | "array" | "null";
14
- /**
15
- * Primitive type
16
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1
17
- */
18
- type JSONSchema7Type = string //
19
- | number | boolean | JSONSchema7Object | JSONSchema7Array | null;
20
- // Workaround for infinite type recursion
21
- interface JSONSchema7Object {
22
- [key: string]: JSONSchema7Type;
23
- }
24
- // Workaround for infinite type recursion
25
- // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540
26
- interface JSONSchema7Array extends Array<JSONSchema7Type> {}
27
- /**
28
- * Meta schema
29
- *
30
- * Recommended values:
31
- * - 'http://json-schema.org/schema#'
32
- * - 'http://json-schema.org/hyper-schema#'
33
- * - 'http://json-schema.org/draft-07/schema#'
34
- * - 'http://json-schema.org/draft-07/hyper-schema#'
35
- *
36
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5
37
- */
38
- type JSONSchema7Version = string;
39
- /**
40
- * JSON Schema v7
41
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01
42
- */
43
- type JSONSchema7Definition = JSONSchema7 | boolean;
44
- interface JSONSchema7 {
45
- $id?: string | undefined;
46
- $ref?: string | undefined;
47
- $schema?: JSONSchema7Version | undefined;
48
- $comment?: string | undefined;
49
- /**
50
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4
51
- * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A
52
- */
53
- $defs?: {
54
- [key: string]: JSONSchema7Definition;
55
- } | undefined;
56
- /**
57
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1
58
- */
59
- type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined;
60
- enum?: JSONSchema7Type[] | undefined;
61
- const?: JSONSchema7Type | undefined;
62
- /**
63
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2
64
- */
65
- multipleOf?: number | undefined;
66
- maximum?: number | undefined;
67
- exclusiveMaximum?: number | undefined;
68
- minimum?: number | undefined;
69
- exclusiveMinimum?: number | undefined;
70
- /**
71
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3
72
- */
73
- maxLength?: number | undefined;
74
- minLength?: number | undefined;
75
- pattern?: string | undefined;
76
- /**
77
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4
78
- */
79
- items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined;
80
- additionalItems?: JSONSchema7Definition | undefined;
81
- maxItems?: number | undefined;
82
- minItems?: number | undefined;
83
- uniqueItems?: boolean | undefined;
84
- contains?: JSONSchema7Definition | undefined;
85
- /**
86
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5
87
- */
88
- maxProperties?: number | undefined;
89
- minProperties?: number | undefined;
90
- required?: string[] | undefined;
91
- properties?: {
92
- [key: string]: JSONSchema7Definition;
93
- } | undefined;
94
- patternProperties?: {
95
- [key: string]: JSONSchema7Definition;
96
- } | undefined;
97
- additionalProperties?: JSONSchema7Definition | undefined;
98
- dependencies?: {
99
- [key: string]: JSONSchema7Definition | string[];
100
- } | undefined;
101
- propertyNames?: JSONSchema7Definition | undefined;
102
- /**
103
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6
104
- */
105
- if?: JSONSchema7Definition | undefined;
106
- then?: JSONSchema7Definition | undefined;
107
- else?: JSONSchema7Definition | undefined;
108
- /**
109
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7
110
- */
111
- allOf?: JSONSchema7Definition[] | undefined;
112
- anyOf?: JSONSchema7Definition[] | undefined;
113
- oneOf?: JSONSchema7Definition[] | undefined;
114
- not?: JSONSchema7Definition | undefined;
115
- /**
116
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7
117
- */
118
- format?: string | undefined;
119
- /**
120
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8
121
- */
122
- contentMediaType?: string | undefined;
123
- contentEncoding?: string | undefined;
124
- /**
125
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9
126
- */
127
- definitions?: {
128
- [key: string]: JSONSchema7Definition;
129
- } | undefined;
130
- /**
131
- * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10
132
- */
133
- title?: string | undefined;
134
- description?: string | undefined;
135
- default?: JSONSchema7Type | undefined;
136
- readOnly?: boolean | undefined;
137
- writeOnly?: boolean | undefined;
138
- examples?: JSONSchema7Type | undefined;
139
- }
140
- //#endregion
141
- //#region src/types.d.ts
142
- type Serializable = {
143
- [key: string]: Serializable;
144
- } | Serializable[] | string | number | boolean | null;
145
- type JsonSchema = JsonSchemaObject | boolean;
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
- }
169
- type ParserSelector = (schema: JsonSchemaObject, refs: Refs) => ZodTypeAny;
170
- type ParserOverride = (schema: JsonSchemaObject, refs: Refs) => ZodTypeAny | undefined;
171
- type JsonSchemaToZodOptions = {
172
- withoutDefaults?: boolean;
173
- withoutDescribes?: boolean;
174
- parserOverride?: ParserOverride;
175
- depth?: number;
176
- };
177
- type Refs = JsonSchemaToZodOptions & {
178
- path: Array<string | number>;
179
- seen: Map<object | boolean, {
180
- n: number;
181
- r: ZodTypeAny | undefined;
182
- }>;
183
- /** The document that local `$ref` pointers resolve against. */
184
- root?: JsonSchema;
185
- };
186
- //#endregion
1
+ import { a as JsonSchemaToZodOptions, c as Refs, i as JsonSchemaObject, l as Serializable, n as InvalidPatternReason, o as ParserOverride, r as JsonSchema, s as ParserSelector, t as InvalidPatternError } from "./compile-pattern-blQMRxo5.mjs";
2
+ import { ZodType, ZodTypeAny } from "zod/v3";
187
3
  //#region src/json-schema-to-zod.d.ts
188
- export declare const jsonSchemaToZod: (schema: JsonSchema, options?: JsonSchemaToZodOptions) => z.ZodType;
4
+ export declare const jsonSchemaToZod: (schema: JsonSchema, options?: JsonSchemaToZodOptions) => ZodType;
189
5
  /**
190
6
  * A simplified type for Zod raw shapes that avoids deep type instantiation issues.
191
7
  * This is compatible with ZodRawShape but uses a simpler type signature.
@@ -205,22 +21,4 @@ type SimpleZodRawShape = Record<string, ZodTypeAny>;
205
21
  */
206
22
  export declare const jsonSchemaToZodShape: (schema: JsonSchema, options?: JsonSchemaToZodOptions) => SimpleZodRawShape;
207
23
  //#endregion
208
- //#region src/utils/compile-pattern.d.ts
209
- type InvalidPatternReason = 'syntax' | 'too-long';
210
- /**
211
- * Raised at conversion time when a schema `pattern` cannot be turned into a
212
- * `RegExp`. Conversion fails eagerly, in line with how this package and
213
- * `@composio/json-schema-to-effect-schema` treat other schema defects: a broken
214
- * schema is the tool author's bug, so it surfaces once at construction rather
215
- * than on every validation as if the caller's input were wrong.
216
- */
217
- export declare class InvalidPatternError extends Error {
218
- readonly keyword: 'pattern' | 'patternProperties';
219
- readonly pattern: string;
220
- readonly path: ReadonlyArray<string | number>;
221
- readonly reason: InvalidPatternReason;
222
- readonly name = "InvalidPatternError";
223
- constructor(keyword: 'pattern' | 'patternProperties', pattern: string, path: ReadonlyArray<string | number>, reason: InvalidPatternReason, detail: string, options?: ErrorOptions);
224
- }
225
- //#endregion
226
- export type { InvalidPatternReason, JsonSchema, JsonSchemaObject, JsonSchemaToZodOptions, ParserOverride, ParserSelector, Refs, Serializable };
24
+ export { InvalidPatternError, type InvalidPatternReason, type JsonSchema, type JsonSchemaObject, type JsonSchemaToZodOptions, type ParserOverride, type ParserSelector, type Refs, type Serializable };