@mastra/nestjs 0.1.6-alpha.1 → 0.1.6-alpha.3
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 +18 -0
- package/dist/controllers/mastra.controller.d.ts.map +1 -1
- package/dist/guards/mastra-route.guard.d.ts.map +1 -1
- package/dist/index.cjs +11 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/route-path.d.ts +1 -1
- package/dist/utils/route-path.d.ts.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/nestjs
|
|
2
2
|
|
|
3
|
+
## 0.1.6-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`271c044`](https://github.com/mastra-ai/mastra/commit/271c044f6b79ff38cfa3409f4385fbd26a0f3185), [`75c7c38`](https://github.com/mastra-ai/mastra/commit/75c7c38a4e9af9821931539dd339f57fcc6414e3)]:
|
|
8
|
+
- @mastra/core@1.35.0-alpha.3
|
|
9
|
+
- @mastra/server@1.35.0-alpha.3
|
|
10
|
+
|
|
11
|
+
## 0.1.6-alpha.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Fixed NestJS route matching so configured prefixes are enforced and partial prefix matches are ignored. For example, a prefix of `/api` no longer matches `/apiish/agents`; only `/api` and `/api/*` are treated as Mastra routes. ([#16637](https://github.com/mastra-ai/mastra/pull/16637))
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`816b974`](https://github.com/mastra-ai/mastra/commit/816b974b424e4a1bfae3af30cc41263b6f1c0344), [`816b974`](https://github.com/mastra-ai/mastra/commit/816b974b424e4a1bfae3af30cc41263b6f1c0344), [`b32ba5f`](https://github.com/mastra-ai/mastra/commit/b32ba5fde524b46a4ff1bdf38e30d62a2bb29b04)]:
|
|
18
|
+
- @mastra/core@1.35.0-alpha.2
|
|
19
|
+
- @mastra/server@1.35.0-alpha.2
|
|
20
|
+
|
|
3
21
|
## 0.1.6-alpha.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mastra.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/mastra.controller.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAQjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAIxE;;;;;;GAMG;AACH,qBAIa,gBAAgB;IAED,OAAO,CAAC,QAAQ,CAAC,OAAO;IACnB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAFrB,OAAO,EAAE,mBAAmB,EACvB,YAAY,EAAE,mBAAmB,EAC/B,cAAc,EAAE,qBAAqB;IAGvF;;OAEG;IAEG,aAAa,CAAQ,GAAG,EAAE,OAAO,EAA8B,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"mastra.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/mastra.controller.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAQjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAIxE;;;;;;GAMG;AACH,qBAIa,gBAAgB;IAED,OAAO,CAAC,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AAmB,EAC/B,cAAc,EAAE,qBAAqB,EAC/C,WAAW,EAAE,WAAW,EAChB,aAAa,EAAE,mBAAmB;IAG5E,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"mastra-route.guard.d.ts","sourceRoot":"","sources":["../../src/guards/mastra-route.guard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D;;;;GAIG;AACH,qBACa,gBAAiB,YAAW,WAAW;IAEhC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACf,OAAO,CAAC,QAAQ,CAAC,OAAO;IACnB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAL1B,MAAM,EAAE,MAAM,EACN,OAAO,EAAE,mBAAmB,EACvB,YAAY,EAAE,mBAAmB,EAC/B,cAAc,EAAE,qBAAqB,EAC/C,WAAW,EAAE,WAAW,EAChB,aAAa,EAAE,mBAAmB;IAG5E,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;CAgC/D"}
|
package/dist/index.cjs
CHANGED
|
@@ -12609,7 +12609,10 @@ function getMastraRoutePath(path, prefix) {
|
|
|
12609
12609
|
normalizedPrefix = normalizedPrefix.slice(0, -1);
|
|
12610
12610
|
}
|
|
12611
12611
|
let routePath = path;
|
|
12612
|
-
if (normalizedPrefix
|
|
12612
|
+
if (normalizedPrefix) {
|
|
12613
|
+
if (path !== normalizedPrefix && !path.startsWith(normalizedPrefix + "/")) {
|
|
12614
|
+
return null;
|
|
12615
|
+
}
|
|
12613
12616
|
routePath = path.slice(normalizedPrefix.length);
|
|
12614
12617
|
if (routePath && !routePath.startsWith("/")) {
|
|
12615
12618
|
routePath = "/" + routePath;
|
|
@@ -12833,6 +12836,9 @@ var MastraRouteGuard = class {
|
|
|
12833
12836
|
const request = context.switchToHttp().getRequest();
|
|
12834
12837
|
const method = request.method.toUpperCase();
|
|
12835
12838
|
const routePath = getMastraRoutePath(request.path, this.options.prefix);
|
|
12839
|
+
if (!routePath) {
|
|
12840
|
+
return true;
|
|
12841
|
+
}
|
|
12836
12842
|
const matchResult = this.routeHandler.matchRoute(method, routePath);
|
|
12837
12843
|
if (!matchResult) {
|
|
12838
12844
|
return true;
|
|
@@ -13420,7 +13426,7 @@ exports.TracingInterceptor = class _TracingInterceptor {
|
|
|
13420
13426
|
const request = context.switchToHttp().getRequest();
|
|
13421
13427
|
const response = context.switchToHttp().getResponse();
|
|
13422
13428
|
const routePath = getMastraRoutePath(request.path, this.options.prefix);
|
|
13423
|
-
const matchResult = this.routeHandler.matchRoute(request.method.toUpperCase(), routePath);
|
|
13429
|
+
const matchResult = routePath ? this.routeHandler.matchRoute(request.method.toUpperCase(), routePath) : null;
|
|
13424
13430
|
const routeTemplate = matchResult?.route.path ?? request.route?.path ?? request.path;
|
|
13425
13431
|
const span = tracer.startSpan(`HTTP ${request.method} ${routeTemplate}`, {
|
|
13426
13432
|
kind: otel.SpanKind.SERVER,
|
|
@@ -13564,6 +13570,9 @@ var MastraController = class {
|
|
|
13564
13570
|
const path = req.path;
|
|
13565
13571
|
const method = req.method.toUpperCase();
|
|
13566
13572
|
const routePath = getMastraRoutePath(path, this.options.prefix);
|
|
13573
|
+
if (!routePath) {
|
|
13574
|
+
throw new common.NotFoundException(`Route not found: ${method} ${path}`);
|
|
13575
|
+
}
|
|
13567
13576
|
if (routePath.includes("//")) {
|
|
13568
13577
|
throw new common.NotFoundException(`Route not found: ${method} ${path}`);
|
|
13569
13578
|
}
|