@mastra/nestjs 0.1.9 → 0.1.10-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 +34 -0
- package/dist/filters/mastra-exception.filter.d.ts.map +1 -1
- package/dist/index.cjs +13 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -16
- package/dist/index.js.map +1 -1
- package/dist/interceptors/streaming.interceptor.d.ts.map +1 -1
- package/dist/services/route-handler.service.d.ts +11 -4
- package/dist/services/route-handler.service.d.ts.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @mastra/nestjs
|
|
2
2
|
|
|
3
|
+
## 0.1.10-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 a different `zod` major than the one bundled with this adapter. 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`. ([#17172](https://github.com/mastra-ai/mastra/pull/17172))
|
|
8
|
+
|
|
9
|
+
`ValidationError.zodError` is now typed as `ZodErrorLike` (a structural subset of `ZodError` exposing `issues[]`) so consumers pinning a different `zod` major still type-check. The runtime value is unchanged; cast to your installed `ZodError` type if you need its instance methods.
|
|
10
|
+
|
|
11
|
+
Fixes [#17167](https://github.com/mastra-ai/mastra/issues/17167).
|
|
12
|
+
|
|
13
|
+
- 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)]:
|
|
14
|
+
- @mastra/core@1.38.0-alpha.2
|
|
15
|
+
- @mastra/server@1.38.0-alpha.2
|
|
16
|
+
|
|
17
|
+
## 0.1.10-alpha.1
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Added sseFlushOnConnect route option to scope the SSE connected comment to subscribe endpoints only ([#17158](https://github.com/mastra-ai/mastra/pull/17158))
|
|
22
|
+
|
|
23
|
+
- Scoped the SSE connected comment to subscribe routes only and added SSE comment passthrough for Fastify and NestJS adapters ([#17158](https://github.com/mastra-ai/mastra/pull/17158))
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`9d87d68`](https://github.com/mastra-ai/mastra/commit/9d87d688371f5d1252ebb18d96890b51ade7de7c), [`49f8abc`](https://github.com/mastra-ai/mastra/commit/49f8abce8258e4f2f87bd326acfbdb641264a47c), [`9d87d68`](https://github.com/mastra-ai/mastra/commit/9d87d688371f5d1252ebb18d96890b51ade7de7c)]:
|
|
26
|
+
- @mastra/server@1.37.2-alpha.1
|
|
27
|
+
- @mastra/core@1.37.2-alpha.1
|
|
28
|
+
|
|
29
|
+
## 0.1.10-alpha.0
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [[`07c3de7`](https://github.com/mastra-ai/mastra/commit/07c3de7f7bc418beccaea3b5e6b7f7cdda79d492)]:
|
|
34
|
+
- @mastra/core@1.37.2-alpha.0
|
|
35
|
+
- @mastra/server@1.37.2-alpha.0
|
|
36
|
+
|
|
3
37
|
## 0.1.9
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mastra-exception.filter.d.ts","sourceRoot":"","sources":["../../src/filters/mastra-exception.filter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"mastra-exception.filter.d.ts","sourceRoot":"","sources":["../../src/filters/mastra-exception.filter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAYrE;;;;;;;;;;;;;GAaG;AACH,qBACa,qBAAsB,YAAW,eAAe;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0C;IAEjE,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI;IAkCpD;;OAEG;IACH,OAAO,CAAC,cAAc;IAgHtB;;OAEG;IACH,OAAO,CAAC,YAAY;CAkCrB"}
|
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
var common = require('@nestjs/common');
|
|
4
4
|
var serverAdapter = require('@mastra/server/server-adapter');
|
|
5
5
|
var error = require('@mastra/server/handlers/error');
|
|
6
|
-
var zod = require('zod');
|
|
7
6
|
var auth = require('@mastra/server/auth');
|
|
8
7
|
var requestContext = require('@mastra/core/request-context');
|
|
9
8
|
var core = require('@nestjs/core');
|
|
@@ -11670,10 +11669,6 @@ function _ts_param(paramIndex, decorator) {
|
|
|
11670
11669
|
};
|
|
11671
11670
|
}
|
|
11672
11671
|
__name(_ts_param, "_ts_param");
|
|
11673
|
-
function isZodErrorLike(error) {
|
|
11674
|
-
return error instanceof zod.ZodError || typeof error === "object" && error !== null && "name" in error && error.name === "ZodError" && "issues" in error && Array.isArray(error.issues);
|
|
11675
|
-
}
|
|
11676
|
-
__name(isZodErrorLike, "isZodErrorLike");
|
|
11677
11672
|
exports.RouteHandlerService = class _RouteHandlerService {
|
|
11678
11673
|
static {
|
|
11679
11674
|
__name(this, "RouteHandlerService");
|
|
@@ -11792,7 +11787,7 @@ exports.RouteHandlerService = class _RouteHandlerService {
|
|
|
11792
11787
|
try {
|
|
11793
11788
|
validatedPathParams = await route.pathParamSchema.parseAsync(params.pathParams);
|
|
11794
11789
|
} catch (error) {
|
|
11795
|
-
if (
|
|
11790
|
+
if (serverAdapter.isZodError(error)) {
|
|
11796
11791
|
throw new ValidationError("Invalid path parameters", error);
|
|
11797
11792
|
}
|
|
11798
11793
|
throw error;
|
|
@@ -11803,7 +11798,7 @@ exports.RouteHandlerService = class _RouteHandlerService {
|
|
|
11803
11798
|
try {
|
|
11804
11799
|
validatedQueryParams = await route.queryParamSchema.parseAsync(params.queryParams);
|
|
11805
11800
|
} catch (error) {
|
|
11806
|
-
if (
|
|
11801
|
+
if (serverAdapter.isZodError(error)) {
|
|
11807
11802
|
throw new ValidationError("Invalid query parameters", error);
|
|
11808
11803
|
}
|
|
11809
11804
|
throw error;
|
|
@@ -11814,7 +11809,7 @@ exports.RouteHandlerService = class _RouteHandlerService {
|
|
|
11814
11809
|
try {
|
|
11815
11810
|
validatedBody = await route.bodySchema.parseAsync(params.body);
|
|
11816
11811
|
} catch (error) {
|
|
11817
|
-
if (
|
|
11812
|
+
if (serverAdapter.isZodError(error)) {
|
|
11818
11813
|
throw new ValidationError("Invalid request body", error);
|
|
11819
11814
|
}
|
|
11820
11815
|
throw error;
|
|
@@ -11838,7 +11833,8 @@ exports.RouteHandlerService = class _RouteHandlerService {
|
|
|
11838
11833
|
return {
|
|
11839
11834
|
data,
|
|
11840
11835
|
responseType: route.responseType,
|
|
11841
|
-
streamFormat: route.streamFormat
|
|
11836
|
+
streamFormat: route.streamFormat,
|
|
11837
|
+
sseFlushOnConnect: route.sseFlushOnConnect
|
|
11842
11838
|
};
|
|
11843
11839
|
}
|
|
11844
11840
|
getRouteKey(method, path) {
|
|
@@ -11888,10 +11884,6 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
11888
11884
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11889
11885
|
}
|
|
11890
11886
|
__name(_ts_decorate2, "_ts_decorate");
|
|
11891
|
-
function isZodErrorLike2(exception) {
|
|
11892
|
-
return exception instanceof zod.ZodError || typeof exception === "object" && exception !== null && "name" in exception && exception.name === "ZodError" && "issues" in exception && Array.isArray(exception.issues);
|
|
11893
|
-
}
|
|
11894
|
-
__name(isZodErrorLike2, "isZodErrorLike");
|
|
11895
11887
|
exports.MastraExceptionFilter = class _MastraExceptionFilter {
|
|
11896
11888
|
static {
|
|
11897
11889
|
__name(this, "MastraExceptionFilter");
|
|
@@ -11963,7 +11955,7 @@ exports.MastraExceptionFilter = class _MastraExceptionFilter {
|
|
|
11963
11955
|
code: this.getErrorCode(status)
|
|
11964
11956
|
};
|
|
11965
11957
|
}
|
|
11966
|
-
if (
|
|
11958
|
+
if (error.isZodError(exception)) {
|
|
11967
11959
|
const formatted = error.formatZodError(exception, "request");
|
|
11968
11960
|
return {
|
|
11969
11961
|
status: common.HttpStatus.BAD_REQUEST,
|
|
@@ -12984,6 +12976,9 @@ exports.StreamingInterceptor = class _StreamingInterceptor {
|
|
|
12984
12976
|
if (streamFormat === "sse") {
|
|
12985
12977
|
response.setHeader("X-Accel-Buffering", "no");
|
|
12986
12978
|
}
|
|
12979
|
+
if (streamFormat === "sse" && result.sseFlushOnConnect) {
|
|
12980
|
+
response.write(": connected\n\n");
|
|
12981
|
+
}
|
|
12987
12982
|
const data = result.data;
|
|
12988
12983
|
const hasFullStream = data !== null && typeof data === "object" && "fullStream" in data;
|
|
12989
12984
|
const stream = hasFullStream ? data.fullStream : data;
|
|
@@ -13004,6 +12999,10 @@ exports.StreamingInterceptor = class _StreamingInterceptor {
|
|
|
13004
12999
|
break;
|
|
13005
13000
|
}
|
|
13006
13001
|
if (value) {
|
|
13002
|
+
if (streamFormat === "sse" && typeof value === "string" && value.startsWith(":")) {
|
|
13003
|
+
response.write(value);
|
|
13004
|
+
continue;
|
|
13005
|
+
}
|
|
13007
13006
|
const outputValue = shouldRedact ? serverAdapter.redactStreamChunk(value) : value;
|
|
13008
13007
|
if (streamFormat === "sse") {
|
|
13009
13008
|
response.write(`data: ${JSON.stringify(outputValue)}
|