@mastra/fastify 1.3.26-alpha.1 → 1.3.26-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 +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @mastra/fastify
|
|
2
2
|
|
|
3
|
+
## 1.3.26-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.3.26-alpha.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -6,174 +6,6 @@ var requestContext = require('@mastra/core/request-context');
|
|
|
6
6
|
var auth = require('@mastra/server/auth');
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
|
-
|
|
10
|
-
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/core.js
|
|
11
|
-
var _a;
|
|
12
|
-
// @__NO_SIDE_EFFECTS__
|
|
13
|
-
function $constructor(name, initializer3, params) {
|
|
14
|
-
function init(inst, def) {
|
|
15
|
-
if (!inst._zod) {
|
|
16
|
-
Object.defineProperty(inst, "_zod", {
|
|
17
|
-
value: {
|
|
18
|
-
def,
|
|
19
|
-
constr: _,
|
|
20
|
-
traits: /* @__PURE__ */ new Set()
|
|
21
|
-
},
|
|
22
|
-
enumerable: false
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
if (inst._zod.traits.has(name)) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
inst._zod.traits.add(name);
|
|
29
|
-
initializer3(inst, def);
|
|
30
|
-
const proto = _.prototype;
|
|
31
|
-
const keys = Object.keys(proto);
|
|
32
|
-
for (let i = 0; i < keys.length; i++) {
|
|
33
|
-
const k = keys[i];
|
|
34
|
-
if (!(k in inst)) {
|
|
35
|
-
inst[k] = proto[k].bind(inst);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const Parent = params?.Parent ?? Object;
|
|
40
|
-
class Definition extends Parent {
|
|
41
|
-
}
|
|
42
|
-
Object.defineProperty(Definition, "name", { value: name });
|
|
43
|
-
function _(def) {
|
|
44
|
-
var _a2;
|
|
45
|
-
const inst = params?.Parent ? new Definition() : this;
|
|
46
|
-
init(inst, def);
|
|
47
|
-
(_a2 = inst._zod).deferred ?? (_a2.deferred = []);
|
|
48
|
-
for (const fn of inst._zod.deferred) {
|
|
49
|
-
fn();
|
|
50
|
-
}
|
|
51
|
-
return inst;
|
|
52
|
-
}
|
|
53
|
-
Object.defineProperty(_, "init", { value: init });
|
|
54
|
-
Object.defineProperty(_, Symbol.hasInstance, {
|
|
55
|
-
value: (inst) => {
|
|
56
|
-
if (params?.Parent && inst instanceof params.Parent)
|
|
57
|
-
return true;
|
|
58
|
-
return inst?._zod?.traits?.has(name);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
Object.defineProperty(_, "name", { value: name });
|
|
62
|
-
return _;
|
|
63
|
-
}
|
|
64
|
-
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
65
|
-
|
|
66
|
-
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/util.js
|
|
67
|
-
function jsonStringifyReplacer(_, value) {
|
|
68
|
-
if (typeof value === "bigint")
|
|
69
|
-
return value.toString();
|
|
70
|
-
return value;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/core/errors.js
|
|
74
|
-
var initializer = (inst, def) => {
|
|
75
|
-
inst.name = "$ZodError";
|
|
76
|
-
Object.defineProperty(inst, "_zod", {
|
|
77
|
-
value: inst._zod,
|
|
78
|
-
enumerable: false
|
|
79
|
-
});
|
|
80
|
-
Object.defineProperty(inst, "issues", {
|
|
81
|
-
value: def,
|
|
82
|
-
enumerable: false
|
|
83
|
-
});
|
|
84
|
-
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
85
|
-
Object.defineProperty(inst, "toString", {
|
|
86
|
-
value: () => inst.message,
|
|
87
|
-
enumerable: false
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
var $ZodError = $constructor("$ZodError", initializer);
|
|
91
|
-
function flattenError(error, mapper = (issue) => issue.message) {
|
|
92
|
-
const fieldErrors = {};
|
|
93
|
-
const formErrors = [];
|
|
94
|
-
for (const sub of error.issues) {
|
|
95
|
-
if (sub.path.length > 0) {
|
|
96
|
-
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
|
97
|
-
fieldErrors[sub.path[0]].push(mapper(sub));
|
|
98
|
-
} else {
|
|
99
|
-
formErrors.push(mapper(sub));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return { formErrors, fieldErrors };
|
|
103
|
-
}
|
|
104
|
-
function formatError(error, mapper = (issue) => issue.message) {
|
|
105
|
-
const fieldErrors = { _errors: [] };
|
|
106
|
-
const processError = (error2, path = []) => {
|
|
107
|
-
for (const issue of error2.issues) {
|
|
108
|
-
if (issue.code === "invalid_union" && issue.errors.length) {
|
|
109
|
-
issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
|
|
110
|
-
} else if (issue.code === "invalid_key") {
|
|
111
|
-
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
112
|
-
} else if (issue.code === "invalid_element") {
|
|
113
|
-
processError({ issues: issue.issues }, [...path, ...issue.path]);
|
|
114
|
-
} else {
|
|
115
|
-
const fullpath = [...path, ...issue.path];
|
|
116
|
-
if (fullpath.length === 0) {
|
|
117
|
-
fieldErrors._errors.push(mapper(issue));
|
|
118
|
-
} else {
|
|
119
|
-
let curr = fieldErrors;
|
|
120
|
-
let i = 0;
|
|
121
|
-
while (i < fullpath.length) {
|
|
122
|
-
const el = fullpath[i];
|
|
123
|
-
const terminal = i === fullpath.length - 1;
|
|
124
|
-
if (!terminal) {
|
|
125
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
126
|
-
} else {
|
|
127
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
128
|
-
curr[el]._errors.push(mapper(issue));
|
|
129
|
-
}
|
|
130
|
-
curr = curr[el];
|
|
131
|
-
i++;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
processError(error);
|
|
138
|
-
return fieldErrors;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/errors.js
|
|
142
|
-
var initializer2 = (inst, issues) => {
|
|
143
|
-
$ZodError.init(inst, issues);
|
|
144
|
-
inst.name = "ZodError";
|
|
145
|
-
Object.defineProperties(inst, {
|
|
146
|
-
format: {
|
|
147
|
-
value: (mapper) => formatError(inst, mapper)
|
|
148
|
-
// enumerable: false,
|
|
149
|
-
},
|
|
150
|
-
flatten: {
|
|
151
|
-
value: (mapper) => flattenError(inst, mapper)
|
|
152
|
-
// enumerable: false,
|
|
153
|
-
},
|
|
154
|
-
addIssue: {
|
|
155
|
-
value: (issue) => {
|
|
156
|
-
inst.issues.push(issue);
|
|
157
|
-
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
158
|
-
}
|
|
159
|
-
// enumerable: false,
|
|
160
|
-
},
|
|
161
|
-
addIssues: {
|
|
162
|
-
value: (issues2) => {
|
|
163
|
-
inst.issues.push(...issues2);
|
|
164
|
-
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
165
|
-
}
|
|
166
|
-
// enumerable: false,
|
|
167
|
-
},
|
|
168
|
-
isEmpty: {
|
|
169
|
-
get() {
|
|
170
|
-
return inst.issues.length === 0;
|
|
171
|
-
}
|
|
172
|
-
// enumerable: false,
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
};
|
|
176
|
-
var ZodError = /* @__PURE__ */ $constructor("ZodError", initializer2);
|
|
177
9
|
function toWebRequest(request) {
|
|
178
10
|
const protocol = request.protocol || "http";
|
|
179
11
|
const host = request.headers.host || "localhost";
|
|
@@ -645,7 +477,7 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
645
477
|
this.mastra.getLogger()?.error("Error parsing query params", {
|
|
646
478
|
error: error instanceof Error ? { message: error.message, stack: error.stack } : error
|
|
647
479
|
});
|
|
648
|
-
if (error
|
|
480
|
+
if (serverAdapter.isZodError(error)) {
|
|
649
481
|
const { status, body } = this.resolveValidationError(route, error, "query");
|
|
650
482
|
return reply.status(status).send(body);
|
|
651
483
|
}
|
|
@@ -662,7 +494,7 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
662
494
|
this.mastra.getLogger()?.error("Error parsing body", {
|
|
663
495
|
error: error instanceof Error ? { message: error.message, stack: error.stack } : error
|
|
664
496
|
});
|
|
665
|
-
if (error
|
|
497
|
+
if (serverAdapter.isZodError(error)) {
|
|
666
498
|
const { status, body } = this.resolveValidationError(route, error, "body");
|
|
667
499
|
return reply.status(status).send(body);
|
|
668
500
|
}
|
|
@@ -679,7 +511,7 @@ var MastraServer = class extends serverAdapter.MastraServer {
|
|
|
679
511
|
this.mastra.getLogger()?.error("Error parsing path params", {
|
|
680
512
|
error: error instanceof Error ? { message: error.message, stack: error.stack } : error
|
|
681
513
|
});
|
|
682
|
-
if (error
|
|
514
|
+
if (serverAdapter.isZodError(error)) {
|
|
683
515
|
const { status, body } = this.resolveValidationError(route, error, "path");
|
|
684
516
|
return reply.status(status).send(body);
|
|
685
517
|
}
|