@hoangvu12/yomi 0.1.0 → 1.0.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/README.md +8 -1
- package/dist/coerce.d.ts +1 -1
- package/dist/coerce.d.ts.map +1 -1
- package/dist/coerce.js +176 -175
- package/dist/coerce.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
**Yomi** (pronounced "yoh-mee", 読み) means "reading" or "interpretation" in Japanese. This library interprets messy LLM output and coerces it to match your Zod schemas.
|
|
4
4
|
|
|
5
|
+
## Version Compatibility
|
|
6
|
+
|
|
7
|
+
| Yomi Version | Zod Version | Notes |
|
|
8
|
+
|--------------|-------------|-------|
|
|
9
|
+
| 1.x | ^4.0.0 | Zod v4 support with new instanceof-based type checking |
|
|
10
|
+
| 0.x | ^3.20.0 | Zod v3 support (legacy) |
|
|
11
|
+
|
|
5
12
|
## The Problem
|
|
6
13
|
|
|
7
14
|
LLMs don't return perfect JSON. They return:
|
|
@@ -184,7 +191,7 @@ LLM Output (string)
|
|
|
184
191
|
Result<T>
|
|
185
192
|
```
|
|
186
193
|
|
|
187
|
-
The coercer recursively walks your Zod schema using `schema
|
|
194
|
+
The coercer recursively walks your Zod schema using `instanceof` checks (Zod v4) to identify schema types, dispatching to type-specific coercion functions. Each coercer tries to interpret the input value as the expected type, recording flags when transformations occur.
|
|
188
195
|
|
|
189
196
|
## License
|
|
190
197
|
|
package/dist/coerce.d.ts
CHANGED
package/dist/coerce.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce.d.ts","sourceRoot":"","sources":["../src/coerce.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"coerce.d.ts","sourceRoot":"","sources":["../src/coerce.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,YAAY,EAIlB,MAAM,YAAY,CAAC;AAcpB;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EACnD,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,OAAO,EACd,GAAG,CAAC,EAAE,aAAa,GAClB,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAG1B"}
|
package/dist/coerce.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as z from "zod";
|
|
2
2
|
import { createContext, failure, describeType, } from "./types.js";
|
|
3
3
|
import { coerceString, coerceNumber, coerceInt, coerceBoolean, coerceNull, coerceLiteral, } from "./coercers/primitive.js";
|
|
4
4
|
import { coerceArray, coerceTuple } from "./coercers/array.js";
|
|
@@ -14,194 +14,195 @@ export function coerceToSchema(schema, value, ctx) {
|
|
|
14
14
|
return coerceZodType(schema, value, context);
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Zod v4 removed ZodFirstPartyTypeKind enum, so we use instanceof checks instead.
|
|
18
|
+
* Type assertions are needed because v4's internal $ZodType doesn't match public ZodType.
|
|
18
19
|
*/
|
|
19
20
|
function coerceZodType(schema, value, ctx) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return failure("Expected undefined", ctx, "undefined", describeType(value));
|
|
39
|
-
case z.ZodFirstPartyTypeKind.ZodVoid:
|
|
21
|
+
if (schema instanceof z.ZodString) {
|
|
22
|
+
return coerceString(value, ctx);
|
|
23
|
+
}
|
|
24
|
+
if (schema instanceof z.ZodNumber) {
|
|
25
|
+
return coerceNumber(value, ctx);
|
|
26
|
+
}
|
|
27
|
+
if (schema instanceof z.ZodBigInt) {
|
|
28
|
+
return coerceInt(value, ctx);
|
|
29
|
+
}
|
|
30
|
+
if (schema instanceof z.ZodBoolean) {
|
|
31
|
+
return coerceBoolean(value, ctx);
|
|
32
|
+
}
|
|
33
|
+
if (schema instanceof z.ZodNull) {
|
|
34
|
+
return coerceNull(value, ctx);
|
|
35
|
+
}
|
|
36
|
+
if (schema instanceof z.ZodUndefined) {
|
|
37
|
+
if (value === undefined || value === null) {
|
|
40
38
|
return { success: true, value: undefined, flags: ctx.flags };
|
|
41
|
-
case z.ZodFirstPartyTypeKind.ZodAny:
|
|
42
|
-
case z.ZodFirstPartyTypeKind.ZodUnknown:
|
|
43
|
-
return { success: true, value, flags: ctx.flags };
|
|
44
|
-
case z.ZodFirstPartyTypeKind.ZodNever:
|
|
45
|
-
return failure("ZodNever cannot match any value", ctx, "never", describeType(value));
|
|
46
|
-
// Literals
|
|
47
|
-
case z.ZodFirstPartyTypeKind.ZodLiteral:
|
|
48
|
-
return coerceLiteral(value, def.value, ctx);
|
|
49
|
-
// Arrays
|
|
50
|
-
case z.ZodFirstPartyTypeKind.ZodArray:
|
|
51
|
-
return coerceArray(value, (v, c) => coerceZodType(def.type, v, c), ctx);
|
|
52
|
-
// Tuples
|
|
53
|
-
case z.ZodFirstPartyTypeKind.ZodTuple: {
|
|
54
|
-
const items = def.items;
|
|
55
|
-
const coercers = items.map((item) => (v, c) => coerceZodType(item, v, c));
|
|
56
|
-
return coerceTuple(value, coercers, ctx);
|
|
57
|
-
}
|
|
58
|
-
// Objects
|
|
59
|
-
case z.ZodFirstPartyTypeKind.ZodObject: {
|
|
60
|
-
const shape = def.shape();
|
|
61
|
-
const objectSchema = {};
|
|
62
|
-
for (const [key, propSchema] of Object.entries(shape)) {
|
|
63
|
-
const isOptional = propSchema.isOptional();
|
|
64
|
-
const hasDefault = propSchema._def.typeName === z.ZodFirstPartyTypeKind.ZodDefault;
|
|
65
|
-
objectSchema[key] = {
|
|
66
|
-
coercer: (v, c) => coerceZodType(propSchema, v, c),
|
|
67
|
-
optional: isOptional,
|
|
68
|
-
...(hasDefault ? { default: propSchema._def.defaultValue() } : {}),
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
return coerceObject(value, objectSchema, ctx);
|
|
72
39
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
40
|
+
return failure("Expected undefined", ctx, "undefined", describeType(value));
|
|
41
|
+
}
|
|
42
|
+
if (schema instanceof z.ZodVoid) {
|
|
43
|
+
return { success: true, value: undefined, flags: ctx.flags };
|
|
44
|
+
}
|
|
45
|
+
if (schema instanceof z.ZodAny || schema instanceof z.ZodUnknown) {
|
|
46
|
+
return { success: true, value, flags: ctx.flags };
|
|
47
|
+
}
|
|
48
|
+
if (schema instanceof z.ZodNever) {
|
|
49
|
+
return failure("ZodNever cannot match any value", ctx, "never", describeType(value));
|
|
50
|
+
}
|
|
51
|
+
if (schema instanceof z.ZodLiteral) {
|
|
52
|
+
// v4 changed from single value to Set to support z.literal("a", "b")
|
|
53
|
+
const literalValue = schema.values.values().next().value;
|
|
54
|
+
return coerceLiteral(value, literalValue, ctx);
|
|
55
|
+
}
|
|
56
|
+
if (schema instanceof z.ZodArray) {
|
|
57
|
+
const elementSchema = schema.element;
|
|
58
|
+
return coerceArray(value, (v, c) => coerceZodType(elementSchema, v, c), ctx);
|
|
59
|
+
}
|
|
60
|
+
if (schema instanceof z.ZodTuple) {
|
|
61
|
+
// v4 exposes items via def, not as a direct property
|
|
62
|
+
const items = schema.def.items;
|
|
63
|
+
const coercers = items.map((item) => (v, c) => coerceZodType(item, v, c));
|
|
64
|
+
return coerceTuple(value, coercers, ctx);
|
|
65
|
+
}
|
|
66
|
+
if (schema instanceof z.ZodObject) {
|
|
67
|
+
const shape = schema.shape;
|
|
68
|
+
const objectSchema = {};
|
|
69
|
+
for (const [key, propSchema] of Object.entries(shape)) {
|
|
70
|
+
const isOptional = propSchema.isOptional();
|
|
71
|
+
const hasDefault = propSchema instanceof z.ZodDefault;
|
|
72
|
+
objectSchema[key] = {
|
|
73
|
+
coercer: (v, c) => coerceZodType(propSchema, v, c),
|
|
74
|
+
optional: isOptional,
|
|
75
|
+
// v4 changed defaultValue from function to direct value
|
|
76
|
+
...(hasDefault ? { default: propSchema.def.defaultValue } : {}),
|
|
77
|
+
};
|
|
90
78
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
79
|
+
return coerceObject(value, objectSchema, ctx);
|
|
80
|
+
}
|
|
81
|
+
if (schema instanceof z.ZodRecord) {
|
|
82
|
+
const valueSchema = schema.valueType;
|
|
83
|
+
return coerceRecord(value, (v, c) => coerceZodType(valueSchema, v, c), ctx);
|
|
84
|
+
}
|
|
85
|
+
if (schema instanceof z.ZodMap) {
|
|
86
|
+
// Treat Map as Record for JSON coercion since JSON has no Map type
|
|
87
|
+
const valueSchema = schema.valueType;
|
|
88
|
+
return coerceRecord(value, (v, c) => coerceZodType(valueSchema, v, c), ctx);
|
|
89
|
+
}
|
|
90
|
+
if (schema instanceof z.ZodUnion) {
|
|
91
|
+
const options = schema.options;
|
|
92
|
+
const coercers = options.map((opt) => (v, c) => coerceZodType(opt, v, c));
|
|
93
|
+
return coerceUnion(value, coercers, ctx);
|
|
94
|
+
}
|
|
95
|
+
if (schema instanceof z.ZodDiscriminatedUnion) {
|
|
96
|
+
const options = schema.options;
|
|
97
|
+
const coercers = options.map((opt) => (v, c) => coerceZodType(opt, v, c));
|
|
98
|
+
return coerceUnion(value, coercers, ctx);
|
|
99
|
+
}
|
|
100
|
+
if (schema instanceof z.ZodOptional) {
|
|
101
|
+
const innerSchema = schema.unwrap();
|
|
102
|
+
return coerceOptional(value, (v, c) => coerceZodType(innerSchema, v, c), ctx);
|
|
103
|
+
}
|
|
104
|
+
if (schema instanceof z.ZodNullable) {
|
|
105
|
+
const innerSchema = schema.unwrap();
|
|
106
|
+
return coerceNullable(value, (v, c) => coerceZodType(innerSchema, v, c), ctx);
|
|
107
|
+
}
|
|
108
|
+
if (schema instanceof z.ZodDefault) {
|
|
109
|
+
const innerSchema = schema.removeDefault();
|
|
110
|
+
// v4 changed defaultValue from function to direct value
|
|
111
|
+
const defaultValue = schema.def.defaultValue;
|
|
112
|
+
return coerceDefault(value, (v, c) => coerceZodType(innerSchema, v, c), defaultValue, ctx);
|
|
113
|
+
}
|
|
114
|
+
if (schema instanceof z.ZodCatch) {
|
|
115
|
+
const innerSchema = schema.removeCatch();
|
|
116
|
+
const result = coerceZodType(innerSchema, value, ctx);
|
|
117
|
+
if (result.success)
|
|
118
|
+
return result;
|
|
119
|
+
// v4 catchValue requires error/value/input/issues context
|
|
120
|
+
const catchDef = schema.def;
|
|
121
|
+
const catchValue = catchDef.catchValue({ error: new z.ZodError([]), value, input: value, issues: [] });
|
|
122
|
+
return { success: true, value: catchValue, flags: ctx.flags };
|
|
123
|
+
}
|
|
124
|
+
if (schema instanceof z.ZodEnum) {
|
|
125
|
+
// v4 uses ZodEnum for both z.enum() and z.nativeEnum() - differentiate by 'enum' property
|
|
126
|
+
const schemaAny = schema;
|
|
127
|
+
if (schemaAny.enum && typeof schemaAny.enum === 'object' && !Array.isArray(schemaAny.enum)) {
|
|
128
|
+
return coerceNativeEnum(value, schemaAny.enum, ctx);
|
|
105
129
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
130
|
+
return coerceEnum(value, schemaAny.options, ctx);
|
|
131
|
+
}
|
|
132
|
+
if (schema instanceof z.ZodLazy) {
|
|
133
|
+
const lazyDef = schema.def;
|
|
134
|
+
const lazySchema = lazyDef.getter();
|
|
135
|
+
return coerceZodType(lazySchema, value, ctx);
|
|
136
|
+
}
|
|
137
|
+
if (schema instanceof z.ZodPipe) {
|
|
138
|
+
// v4 renamed ZodPipeline to ZodPipe
|
|
139
|
+
const inSchema = schema.in;
|
|
140
|
+
const outSchema = schema.out;
|
|
141
|
+
const inResult = coerceZodType(inSchema, value, ctx);
|
|
142
|
+
if (!inResult.success)
|
|
143
|
+
return inResult;
|
|
144
|
+
return coerceZodType(outSchema, inResult.value, ctx);
|
|
145
|
+
}
|
|
146
|
+
if (schema instanceof z.ZodReadonly) {
|
|
147
|
+
const readonlyDef = schema.def;
|
|
148
|
+
return coerceZodType(readonlyDef.innerType, value, ctx);
|
|
149
|
+
}
|
|
150
|
+
if (schema instanceof z.ZodDate) {
|
|
151
|
+
if (value instanceof Date) {
|
|
152
|
+
if (isNaN(value.getTime())) {
|
|
153
|
+
return failure("Invalid Date", ctx, "Date", "Invalid Date");
|
|
131
154
|
}
|
|
132
|
-
return
|
|
133
|
-
}
|
|
134
|
-
// Lazy
|
|
135
|
-
case z.ZodFirstPartyTypeKind.ZodLazy:
|
|
136
|
-
return coerceZodType(def.getter(), value, ctx);
|
|
137
|
-
// Branded
|
|
138
|
-
case z.ZodFirstPartyTypeKind.ZodBranded:
|
|
139
|
-
return coerceZodType(def.type, value, ctx);
|
|
140
|
-
// Pipeline
|
|
141
|
-
case z.ZodFirstPartyTypeKind.ZodPipeline: {
|
|
142
|
-
const inResult = coerceZodType(def.in, value, ctx);
|
|
143
|
-
if (!inResult.success)
|
|
144
|
-
return inResult;
|
|
145
|
-
return coerceZodType(def.out, inResult.value, ctx);
|
|
155
|
+
return { success: true, value, flags: ctx.flags };
|
|
146
156
|
}
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
if (value instanceof Date) {
|
|
153
|
-
if (isNaN(value.getTime())) {
|
|
154
|
-
return failure("Invalid Date", ctx, "Date", "Invalid Date");
|
|
155
|
-
}
|
|
156
|
-
return { success: true, value, flags: ctx.flags };
|
|
157
|
-
}
|
|
158
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
159
|
-
const date = new Date(value);
|
|
160
|
-
if (isNaN(date.getTime())) {
|
|
161
|
-
return failure(`Cannot parse "${value}" as Date`, ctx, "Date", describeType(value));
|
|
162
|
-
}
|
|
163
|
-
return { success: true, value: date, flags: ctx.flags };
|
|
157
|
+
// LLMs often return dates as strings - attempt parsing
|
|
158
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
159
|
+
const date = new Date(value);
|
|
160
|
+
if (isNaN(date.getTime())) {
|
|
161
|
+
return failure(`Cannot parse "${value}" as Date`, ctx, "Date", describeType(value));
|
|
164
162
|
}
|
|
165
|
-
return
|
|
163
|
+
return { success: true, value: date, flags: ctx.flags };
|
|
166
164
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (typeof leftResult.value === "object" && typeof rightResult.value === "object") {
|
|
177
|
-
return { success: true, value: { ...leftResult.value, ...rightResult.value }, flags: ctx.flags };
|
|
178
|
-
}
|
|
165
|
+
return failure("Expected Date", ctx, "Date", describeType(value));
|
|
166
|
+
}
|
|
167
|
+
if (schema instanceof z.ZodIntersection) {
|
|
168
|
+
const intersectionDef = schema.def;
|
|
169
|
+
const leftResult = coerceZodType(intersectionDef.left, value, ctx);
|
|
170
|
+
if (!leftResult.success)
|
|
171
|
+
return leftResult;
|
|
172
|
+
const rightResult = coerceZodType(intersectionDef.right, leftResult.value, ctx);
|
|
173
|
+
if (!rightResult.success)
|
|
179
174
|
return rightResult;
|
|
175
|
+
// Merge object results since intersection typically combines object types
|
|
176
|
+
if (typeof leftResult.value === "object" && typeof rightResult.value === "object") {
|
|
177
|
+
return { success: true, value: { ...leftResult.value, ...rightResult.value }, flags: ctx.flags };
|
|
180
178
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
179
|
+
return rightResult;
|
|
180
|
+
}
|
|
181
|
+
if (schema instanceof z.ZodSet) {
|
|
182
|
+
// Coerce as array first, then convert to Set (JSON has no Set type)
|
|
183
|
+
const setDef = schema.def;
|
|
184
|
+
const arrayResult = coerceArray(value, (v, c) => coerceZodType(setDef.valueType, v, c), ctx);
|
|
185
|
+
if (!arrayResult.success)
|
|
186
|
+
return arrayResult;
|
|
187
|
+
return { success: true, value: new Set(arrayResult.value), flags: ctx.flags };
|
|
188
|
+
}
|
|
189
|
+
if (schema instanceof z.ZodPromise) {
|
|
190
|
+
// Can't coerce promises - pass through
|
|
191
|
+
return { success: true, value, flags: ctx.flags };
|
|
192
|
+
}
|
|
193
|
+
if (schema instanceof z.ZodFunction) {
|
|
194
|
+
if (typeof value === "function") {
|
|
195
|
+
return { success: true, value, flags: ctx.flags };
|
|
187
196
|
}
|
|
188
|
-
|
|
189
|
-
|
|
197
|
+
return failure("Expected function", ctx, "function", describeType(value));
|
|
198
|
+
}
|
|
199
|
+
if (schema instanceof z.ZodSymbol) {
|
|
200
|
+
if (typeof value === "symbol") {
|
|
190
201
|
return { success: true, value, flags: ctx.flags };
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (typeof value === "function") {
|
|
194
|
-
return { success: true, value, flags: ctx.flags };
|
|
195
|
-
}
|
|
196
|
-
return failure("Expected function", ctx, "function", describeType(value));
|
|
197
|
-
// Symbol
|
|
198
|
-
case z.ZodFirstPartyTypeKind.ZodSymbol:
|
|
199
|
-
if (typeof value === "symbol") {
|
|
200
|
-
return { success: true, value, flags: ctx.flags };
|
|
201
|
-
}
|
|
202
|
-
return failure("Expected symbol", ctx, "symbol", describeType(value));
|
|
203
|
-
default:
|
|
204
|
-
return failure(`Unsupported Zod type: ${typeName}`, ctx, typeName, describeType(value));
|
|
202
|
+
}
|
|
203
|
+
return failure("Expected symbol", ctx, "symbol", describeType(value));
|
|
205
204
|
}
|
|
205
|
+
const typeName = schema.constructor.name;
|
|
206
|
+
return failure(`Unsupported Zod type: ${typeName}`, ctx, typeName, describeType(value));
|
|
206
207
|
}
|
|
207
208
|
//# sourceMappingURL=coerce.js.map
|
package/dist/coerce.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coerce.js","sourceRoot":"","sources":["../src/coerce.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"coerce.js","sourceRoot":"","sources":["../src/coerce.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAGL,aAAa,EACb,OAAO,EACP,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAqB,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAElE;;;GAGG;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AK,EAAE,CAAC;IACpD,CAAC;IAED,IAAI,MAAM,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;QACpC,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAChC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;QACpD,CAAC;QACD,OAAO,OAAO,CAAC,mBAAmB,EAAE,GAAG,EAAE,UAAU,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,MAAM,YAAY,CAAC,CAAC,SAAS,EAAE,CAAC;QAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC;QACpD,CAAC;QACD,OAAO,OAAO,CAAC,iBAAiB,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;IACzC,OAAO,OAAO,CAAC,yBAAyB,QAAQ,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1F,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hoangvu12/yomi",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Yomi (読み) - Flexible JSON parser that interprets LLM output to match Zod schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"jsonrepair": "^3.8.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"zod": "^
|
|
46
|
+
"zod": "^4.0.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/node": "^20.10.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"eslint": "^8.56.0",
|
|
53
53
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
54
54
|
"@typescript-eslint/parser": "^6.0.0",
|
|
55
|
-
"zod": "^
|
|
55
|
+
"zod": "^4.0.0"
|
|
56
56
|
},
|
|
57
57
|
"files": [
|
|
58
58
|
"dist"
|