@mastra/hono 1.4.21-alpha.1 → 1.4.21-alpha.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/CHANGELOG.md +10 -0
- package/dist/index.cjs +3 -171
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -172
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @mastra/hono
|
|
2
2
|
|
|
3
|
+
## 1.4.21-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed validation error responses on routes with `bodySchema`, `queryParamSchema`, or `pathParamSchema` losing field path information when consumers pin `zod@^3`. Responses now return the actual field name in `issues[].field` (e.g. `"agent_id"`) instead of `"unknown"` with the raw Zod issues serialized into `issues[0].message`. Fixes [#17167](https://github.com/mastra-ai/mastra/issues/17167). ([#17172](https://github.com/mastra-ai/mastra/pull/17172))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`d779de3`](https://github.com/mastra-ai/mastra/commit/d779de3cd9d2e7ed8110547190e2f15e786a0e41), [`1750c97`](https://github.com/mastra-ai/mastra/commit/1750c975d6179fbf6db2813b15229d4f8f23fc55), [`09972fe`](https://github.com/mastra-ai/mastra/commit/09972fe6b7b92ade32d70deda7094af2e52b2676), [`0e32507`](https://github.com/mastra-ai/mastra/commit/0e32507962cdfa5569b7bda5bc6fb3dd34e40b03), [`3a081c1`](https://github.com/mastra-ai/mastra/commit/3a081c1255c5ae8c99f6dad91cc612934ef6f2bd), [`fe9eacd`](https://github.com/mastra-ai/mastra/commit/fe9eacd9545a0a9d64aad31c9fa90294a425289e), [`db79c86`](https://github.com/mastra-ai/mastra/commit/db79c86c60723d57e02f9636ca2611bd4515f194)]:
|
|
10
|
+
- @mastra/core@1.38.0-alpha.2
|
|
11
|
+
- @mastra/server@1.38.0-alpha.2
|
|
12
|
+
|
|
3
13
|
## 1.4.21-alpha.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -9,174 +9,6 @@ var auth = require('@mastra/server/auth');
|
|
|
9
9
|
var browserStream = require('@mastra/server/browser-stream');
|
|
10
10
|
|
|
11
11
|
// src/index.ts
|
|
12
|
-
|
|
13
|
-
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
|
|
14
|
-
var _a;
|
|
15
|
-
// @__NO_SIDE_EFFECTS__
|
|
16
|
-
function $constructor(name, initializer3, params) {
|
|
17
|
-
function init(inst, def) {
|
|
18
|
-
if (!inst._zod) {
|
|
19
|
-
Object.defineProperty(inst, "_zod", {
|
|
20
|
-
value: {
|
|
21
|
-
def,
|
|
22
|
-
constr: _,
|
|
23
|
-
traits: /* @__PURE__ */ new Set()
|
|
24
|
-
},
|
|
25
|
-
enumerable: false
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
if (inst._zod.traits.has(name)) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
inst._zod.traits.add(name);
|
|
32
|
-
initializer3(inst, def);
|
|
33
|
-
const proto = _.prototype;
|
|
34
|
-
const keys = Object.keys(proto);
|
|
35
|
-
for (let i = 0; i < keys.length; i++) {
|
|
36
|
-
const k = keys[i];
|
|
37
|
-
if (!(k in inst)) {
|
|
38
|
-
inst[k] = proto[k].bind(inst);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const Parent = params?.Parent ?? Object;
|
|
43
|
-
class Definition extends Parent {
|
|
44
|
-
}
|
|
45
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
46
|
-
function _(def) {
|
|
47
|
-
var _a2;
|
|
48
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
49
|
-
init(inst, def);
|
|
50
|
-
(_a2 = inst._zod).deferred ?? (_a2.deferred = []);
|
|
51
|
-
for (const fn of inst._zod.deferred) {
|
|
52
|
-
fn();
|
|
53
|
-
}
|
|
54
|
-
return inst;
|
|
55
|
-
}
|
|
56
|
-
Object.defineProperty(_, "init", { value: init });
|
|
57
|
-
Object.defineProperty(_, Symbol.hasInstance, {
|
|
58
|
-
value: (inst) => {
|
|
59
|
-
if (params?.Parent && inst instanceof params.Parent)
|
|
60
|
-
return true;
|
|
61
|
-
return inst?._zod?.traits?.has(name);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
Object.defineProperty(_, "name", { value: name });
|
|
65
|
-
return _;
|
|
66
|
-
}
|
|
67
|
-
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
68
|
-
|
|
69
|
-
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
|
|
70
|
-
function jsonStringifyReplacer(_, value) {
|
|
71
|
-
if (typeof value === "bigint")
|
|
72
|
-
return value.toString();
|
|
73
|
-
return value;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
|
|
77
|
-
var initializer = (inst, def) => {
|
|
78
|
-
inst.name = "$ZodError";
|
|
79
|
-
Object.defineProperty(inst, "_zod", {
|
|
80
|
-
value: inst._zod,
|
|
81
|
-
enumerable: false
|
|
82
|
-
});
|
|
83
|
-
Object.defineProperty(inst, "issues", {
|
|
84
|
-
value: def,
|
|
85
|
-
enumerable: false
|
|
86
|
-
});
|
|
87
|
-
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
88
|
-
Object.defineProperty(inst, "toString", {
|
|
89
|
-
value: () => inst.message,
|
|
90
|
-
enumerable: false
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
var $ZodError = $constructor("$ZodError", initializer);
|
|
94
|
-
function flattenError(error, mapper = (issue) => issue.message) {
|
|
95
|
-
const fieldErrors = {};
|
|
96
|
-
const formErrors = [];
|
|
97
|
-
for (const sub of error.issues) {
|
|
98
|
-
if (sub.path.length > 0) {
|
|
99
|
-
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
100
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
101
|
-
} else {
|
|
102
|
-
formErrors.push(mapper(sub));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return { formErrors, fieldErrors };
|
|
106
|
-
}
|
|
107
|
-
function formatError(error, mapper = (issue) => issue.message) {
|
|
108
|
-
const fieldErrors = { _errors: [] };
|
|
109
|
-
const processError = (error2, path = []) => {
|
|
110
|
-
for (const issue of error2.issues) {
|
|
111
|
-
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
112
|
-
issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
113
|
-
} else if (issue.code === "invalid_key") {
|
|
114
|
-
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
115
|
-
} else if (issue.code === "invalid_element") {
|
|
116
|
-
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
117
|
-
} else {
|
|
118
|
-
const fullpath = [...path, ...issue.path];
|
|
119
|
-
if (fullpath.length === 0) {
|
|
120
|
-
fieldErrors._errors.push(mapper(issue));
|
|
121
|
-
} else {
|
|
122
|
-
let curr = fieldErrors;
|
|
123
|
-
let i = 0;
|
|
124
|
-
while (i < fullpath.length) {
|
|
125
|
-
const el = fullpath[i];
|
|
126
|
-
const terminal = i === fullpath.length - 1;
|
|
127
|
-
if (!terminal) {
|
|
128
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
129
|
-
} else {
|
|
130
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
131
|
-
curr[el]._errors.push(mapper(issue));
|
|
132
|
-
}
|
|
133
|
-
curr = curr[el];
|
|
134
|
-
i++;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
processError(error);
|
|
141
|
-
return fieldErrors;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
|
|
145
|
-
var initializer2 = (inst, issues) => {
|
|
146
|
-
$ZodError.init(inst, issues);
|
|
147
|
-
inst.name = "ZodError";
|
|
148
|
-
Object.defineProperties(inst, {
|
|
149
|
-
format: {
|
|
150
|
-
value: (mapper) => formatError(inst, mapper)
|
|
151
|
-
// enumerable: false,
|
|
152
|
-
},
|
|
153
|
-
flatten: {
|
|
154
|
-
value: (mapper) => flattenError(inst, mapper)
|
|
155
|
-
// enumerable: false,
|
|
156
|
-
},
|
|
157
|
-
addIssue: {
|
|
158
|
-
value: (issue) => {
|
|
159
|
-
inst.issues.push(issue);
|
|
160
|
-
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
161
|
-
}
|
|
162
|
-
// enumerable: false,
|
|
163
|
-
},
|
|
164
|
-
addIssues: {
|
|
165
|
-
value: (issues2) => {
|
|
166
|
-
inst.issues.push(...issues2);
|
|
167
|
-
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
168
|
-
}
|
|
169
|
-
// enumerable: false,
|
|
170
|
-
},
|
|
171
|
-
isEmpty: {
|
|
172
|
-
get() {
|
|
173
|
-
return inst.issues.length === 0;
|
|
174
|
-
}
|
|
175
|
-
// enumerable: false,
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
var ZodError = /* @__PURE__ */ $constructor("ZodError", initializer2);
|
|
180
12
|
function createAuthMiddleware({ mastra, requiresAuth = true }) {
|
|
181
13
|
return async (c, next) => {
|
|
182
14
|
if (!requiresAuth) {
|
|
@@ -619,7 +451,7 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
619
451
|
this.mastra.getLogger()?.error("Error parsing query params", {
|
|
620
452
|
error: error instanceof Error ? { message: error.message, stack: error.stack } : error
|
|
621
453
|
});
|
|
622
|
-
if (error
|
|
454
|
+
if (serverAdapter.isZodError(error)) {
|
|
623
455
|
const { status, body } = this.resolveValidationError(route, error, "query");
|
|
624
456
|
return c.json(body, status);
|
|
625
457
|
}
|
|
@@ -639,7 +471,7 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
639
471
|
this.mastra.getLogger()?.error("Error parsing body", {
|
|
640
472
|
error: error instanceof Error ? { message: error.message, stack: error.stack } : error
|
|
641
473
|
});
|
|
642
|
-
if (error
|
|
474
|
+
if (serverAdapter.isZodError(error)) {
|
|
643
475
|
const { status, body } = this.resolveValidationError(route, error, "body");
|
|
644
476
|
return c.json(body, status);
|
|
645
477
|
}
|
|
@@ -659,7 +491,7 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
659
491
|
this.mastra.getLogger()?.error("Error parsing path params", {
|
|
660
492
|
error: error instanceof Error ? { message: error.message, stack: error.stack } : error
|
|
661
493
|
});
|
|
662
|
-
if (error
|
|
494
|
+
if (serverAdapter.isZodError(error)) {
|
|
663
495
|
const { status, body } = this.resolveValidationError(route, error, "path");
|
|
664
496
|
return c.json(body, status);
|
|
665
497
|
}
|