@mastra/nestjs 0.2.38 → 0.2.39-alpha.1
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/controllers/mastra.controller.d.ts.map +1 -1
- package/dist/filters/mastra-exception.filter.d.ts.map +1 -1
- package/dist/index.cjs +101 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +102 -15
- package/dist/index.js.map +1 -1
- package/dist/mastra.service.d.ts +2 -0
- package/dist/mastra.service.d.ts.map +1 -1
- package/dist/services/auth.service.d.ts +6 -1
- package/dist/services/auth.service.d.ts.map +1 -1
- package/dist/services/custom-route.service.d.ts +4 -3
- package/dist/services/custom-route.service.d.ts.map +1 -1
- package/dist/services/route-handler.service.d.ts +15 -0
- package/dist/services/route-handler.service.d.ts.map +1 -1
- package/package.json +10 -10
package/dist/mastra.service.d.ts
CHANGED
|
@@ -32,6 +32,8 @@ export declare class MastraService implements OnModuleInit {
|
|
|
32
32
|
constructor(mastra: Mastra, options: MastraModuleOptions, shutdownService: ShutdownService, httpAdapterHost: HttpAdapterHost, routeHandler: RouteHandlerService);
|
|
33
33
|
onModuleInit(): void;
|
|
34
34
|
private initializeServerAdapter;
|
|
35
|
+
/** Mastra server middleware uses Hono's `(c, next)` signature, so NestJS cannot run it. */
|
|
36
|
+
private warnIfServerMiddlewareConfigured;
|
|
35
37
|
/**
|
|
36
38
|
* Get the Mastra instance.
|
|
37
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mastra.service.d.ts","sourceRoot":"","sources":["../src/mastra.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAI/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAC3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Q,CAAC,eAAe;IAC5B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAR5D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkC;IACzD,OAAO,CAAC,aAAa,CAAC,CAAmB;IAEzC,YACmC,MAAM,EAAE,MAAM,EACN,OAAO,EAAE,mBAAmB,EAC3B,eAAe,EAAE,eAAe,EAChC,eAAe,EAAE,eAAe,EAC5B,YAAY,EAAE,mBAAmB,EAGhF;IAED,YAAY,IAAI,IAAI,CAEnB;IAED,OAAO,CAAC,uBAAuB;IAwB/B,2FAA2F;IAC3F,OAAO,CAAC,gCAAgC;IAaxC;;OAEG;IACH,SAAS,IAAI,MAAM,CAElB;IAED;;OAEG;IACH,UAAU,IAAI,mBAAmB,CAEhC;IAED;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,gKAEvB;IAED;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,gDAE7B;IAED;;OAEG;IACH,IAAI,cAAc,IAAI,OAAO,CAE5B;CACF"}
|
|
@@ -26,9 +26,14 @@ export declare class AuthService {
|
|
|
26
26
|
constructor(mastra: Mastra, options: MastraModuleOptions, customRoutes: CustomRouteService);
|
|
27
27
|
/**
|
|
28
28
|
* Whether Mastra auth should run: module options enable it, or the Mastra
|
|
29
|
-
* server has auth configured (unless module options explicitly disable it).
|
|
29
|
+
* server or Studio has auth configured (unless module options explicitly disable it).
|
|
30
30
|
*/
|
|
31
31
|
isEnabled(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Studio requests (`x-mastra-client-type: studio`) use `studio.auth` exclusively when it is
|
|
34
|
+
* configured, without falling back to `server.auth`; all other requests use `server.auth`.
|
|
35
|
+
*/
|
|
36
|
+
private getEffectiveAuthConfig;
|
|
32
37
|
/**
|
|
33
38
|
* Check authentication for a request.
|
|
34
39
|
* Returns the authenticated user if auth succeeds, undefined if no auth required.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAU9D,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,WAAW,mBAAmB;IAClC,kFAAkF;IAClF,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;GAKG;AACH,qBACa,WAAW;IAEJ,OAAO,CAAC,QAAQ,CAAC,MAAM;IACf,OAAO,CAAC,QAAQ,CAAC,OAAO;IACpB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAH3D,YACmC,MAAM,EAAE,MAAM,EACN,OAAO,EAAE,mBAAmB,EACxB,YAAY,EAAE,kBAAkB,EAC3E;IAEJ;;;OAGG;IACH,SAAS,IAAI,OAAO,CAGnB;IAED;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAW9B;;;;OAIG;IACG,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,OAAO,CAAC,CAoExF;IAED;;;OAGG;IACH,OAAO,CAAC,YAAY;CAuBrB"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Mastra } from '@mastra/core/mastra';
|
|
2
2
|
import { RequestContext } from '@mastra/core/request-context';
|
|
3
|
+
import type { ApiRoute } from '@mastra/core/server';
|
|
3
4
|
import type { Request, Response as ExpressResponse } from 'express';
|
|
4
5
|
import type { MastraModuleOptions } from '../mastra.module.js';
|
|
5
|
-
/** Authenticates a matched custom route. Throws to reject the request. */
|
|
6
|
-
export type CustomRouteAuthenticate = (requiresAuth: boolean) => Promise<void>;
|
|
6
|
+
/** Authenticates and authorizes a matched custom route. Throws to reject the request. */
|
|
7
|
+
export type CustomRouteAuthenticate = (route: ApiRoute, requiresAuth: boolean, pathParams: Record<string, string>) => Promise<void>;
|
|
7
8
|
/**
|
|
8
9
|
* Serves custom routes registered with `registerApiRoute()` via `server.apiRoutes`,
|
|
9
10
|
* matching the behavior of the other Mastra server adapters.
|
|
@@ -20,7 +21,7 @@ export declare class CustomRouteService {
|
|
|
20
21
|
* Runs a matched custom route and writes its response.
|
|
21
22
|
* Returns false if no custom route handled the request.
|
|
22
23
|
*
|
|
23
|
-
* `authenticate` runs after Hono's router selects the route, so auth
|
|
24
|
+
* `authenticate` runs after Hono's router selects the route, so auth, RBAC, and FGA are enforced
|
|
24
25
|
* for exactly the routes Hono dispatches (including regex-constrained params).
|
|
25
26
|
*/
|
|
26
27
|
handle(req: Request, res: ExpressResponse, requestContext: RequestContext, authenticate: CustomRouteAuthenticate): Promise<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-route.service.d.ts","sourceRoot":"","sources":["../../src/services/custom-route.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"custom-route.service.d.ts","sourceRoot":"","sources":["../../src/services/custom-route.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,SAAS,CAAC;AAIpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAM5D,yFAAyF;AACzF,MAAM,MAAM,uBAAuB,GAAG,CACpC,KAAK,EAAE,QAAQ,EACf,YAAY,EAAE,OAAO,EACrB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAC/B,OAAO,CAAC,IAAI,CAAC,CAAC;AAMnB;;;GAGG;AACH,qBACa,kBAAkB;IAMX,OAAO,CAAC,QAAQ,CAAC,MAAM;IALzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAClD,OAAO,CAAC,YAAY,CAAC,CAA4B;IAEjD,YACmC,MAAM,EAAE,MAAM,EACvB,OAAO,EAAE,mBAAmB,EAYrD;IAED,6DAA6D;IAC7D,IAAI,qBAAqB,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAEhD;IAED;;;;;;OAMG;IACG,MAAM,CACV,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,eAAe,EACpB,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,uBAAuB,GACpC,OAAO,CAAC,OAAO,CAAC,CAmDlB;YAEa,KAAK;IAuEnB,OAAO,CAAC,cAAc;CAgCvB"}
|
|
@@ -72,6 +72,21 @@ export declare class RouteHandlerService {
|
|
|
72
72
|
* Execute a route handler with the given parameters.
|
|
73
73
|
*/
|
|
74
74
|
executeHandler(route: ServerRoute, params: RouteHandlerParams): Promise<RouteHandlerResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Enforce the route's RBAC permission and FGA check, matching the other server adapters.
|
|
77
|
+
* Relies on the auth guard having stored the user, permissions, and auth mode in the request context.
|
|
78
|
+
*/
|
|
79
|
+
private authorizeRoute;
|
|
80
|
+
/**
|
|
81
|
+
* Throws 403 when the user lacks the route's effective RBAC permission.
|
|
82
|
+
* Skipped when Mastra auth is explicitly disabled (`auth.enabled: false`), since no Mastra user is resolved.
|
|
83
|
+
*/
|
|
84
|
+
enforceRoutePermission(route: ServerRoute, requestContext: RequestContext): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Throws when the FGA provider denies the route's resource.
|
|
87
|
+
* Skipped when Mastra auth is explicitly disabled (`auth.enabled: false`), since no Mastra user is resolved.
|
|
88
|
+
*/
|
|
89
|
+
enforceRouteFGA(route: ServerRoute, requestContext: RequestContext, params: Record<string, unknown>): Promise<void>;
|
|
75
90
|
private parseBody;
|
|
76
91
|
private createValidationError;
|
|
77
92
|
private getRouteKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-handler.service.d.ts","sourceRoot":"","sources":["../../src/services/route-handler.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route-handler.service.d.ts","sourceRoot":"","sources":["../../src/services/route-handler.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AASnE,OAAO,KAAK,EAAE,WAAW,EAAiB,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAI9F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,WAAW,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,kBAAkB;IACjC,qDAAqD;IACrD,UAAU,EAAE,MAAM,CAAC,MAAM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;;OAGG;IACH,OAAO,CAAC,SAAS;IAsCjB;;OAEG;IACG,cAAc,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAoEhG;IAED;;;OAGG;YACW,cAAc;IAS5B;;;OAGG;IACG,sBAAsB,CAAC,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB9F;IAED;;;OAGG;IACG,eAAe,CACnB,KAAK,EAAE,WAAW,EAClB,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC,CAOf;YAEa,SAAS;IA0BvB,OAAO,CAAC,qBAAqB;IA+B7B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,gBAAgB;CAgBzB;AAED;;;;;;;;GAQG;AACH,qBAAa,eAAgB,SAAQ,KAAK;aAGtB,QAAQ,EAAE,YAAY;aACtB,MAAM;aACN,IAAI,EAAE,OAAO;IAJ/B,YACE,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,YAAY,EACtB,MAAM,SAAM,EACZ,IAAI,GAAE,OAA6C,EAIpE;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/nestjs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.39-alpha.1",
|
|
4
4
|
"description": "Mastra NestJS adapter for the server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@fastify/busboy": "^3.2.2",
|
|
24
24
|
"hono": "^4.13.7",
|
|
25
|
-
"@mastra/server": "1.
|
|
25
|
+
"@mastra/server": "1.80.0-alpha.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@ai-sdk/openai": "^2.0.135",
|
|
@@ -39,19 +39,19 @@
|
|
|
39
39
|
"reflect-metadata": "^0.2.2",
|
|
40
40
|
"rxjs": "^7.8.1",
|
|
41
41
|
"supertest": "^7.1.1",
|
|
42
|
-
"tsdown": "0.
|
|
42
|
+
"tsdown": "0.23.1",
|
|
43
43
|
"typescript": "^7.0.2",
|
|
44
|
-
"vitest": "^4.1.
|
|
44
|
+
"vitest": "^4.1.12",
|
|
45
45
|
"zod": "^3.25.0",
|
|
46
|
-
"@mastra/server-adapters-test-suite": "0.1.
|
|
46
|
+
"@mastra/server-adapters-test-suite": "0.1.4-alpha.1",
|
|
47
|
+
"@internal/lint": "0.0.145",
|
|
47
48
|
"@internal/storage-test-utils": "0.0.141",
|
|
48
|
-
"@
|
|
49
|
+
"@mastra/core": "1.80.0-alpha.1",
|
|
49
50
|
"@mastra/evals": "1.10.8",
|
|
50
|
-
"@mastra/memory": "1.39.0",
|
|
51
|
-
"@mastra/core": "1.79.0",
|
|
52
51
|
"@mastra/libsql": "1.27.0",
|
|
53
|
-
"@mastra/
|
|
54
|
-
"@internal/
|
|
52
|
+
"@mastra/memory": "1.39.1-alpha.0",
|
|
53
|
+
"@internal/types-builder": "0.0.120",
|
|
54
|
+
"@mastra/observability": "1.21.1-alpha.1"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@mastra/core": ">=1.58.0-0 <2.0.0-0",
|