@mastra/deployer 1.32.0-alpha.1 → 1.32.0-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.
@@ -12,7 +12,7 @@ import { existsSync, createReadStream, statSync } from 'fs';
12
12
  import { versions } from 'process';
13
13
  import { html } from 'hono/html';
14
14
  import { Tool } from '@mastra/core/tools';
15
- import { MastraServer as MastraServer$1, normalizeQueryParams, redactStreamChunk } from '@mastra/server/server-adapter';
15
+ import { MastraServer as MastraServer$1, normalizeQueryParams, checkRouteFGA, redactStreamChunk } from '@mastra/server/server-adapter';
16
16
  import util from 'util';
17
17
  import { Buffer as Buffer$1 } from 'buffer';
18
18
  import { ViewerRegistry, handleInputMessage } from '@mastra/server/browser-stream';
@@ -3605,6 +3605,14 @@ var MastraServer = class extends MastraServer$1 {
3605
3605
  }
3606
3606
  }
3607
3607
  }
3608
+ const fgaError = await checkRouteFGA(this.mastra, route, c.get("requestContext"), {
3609
+ ...params.urlParams,
3610
+ ...params.queryParams,
3611
+ ...typeof params.body === "object" ? params.body : {}
3612
+ });
3613
+ if (fgaError) {
3614
+ return c.json({ error: fgaError.error, message: fgaError.message }, fgaError.status);
3615
+ }
3608
3616
  try {
3609
3617
  const result = await route.handler(handlerParams);
3610
3618
  return this.sendResponse(route, c, result, prefix);
@@ -3653,7 +3661,9 @@ var MastraServer = class extends MastraServer$1 {
3653
3661
  responseType: "json",
3654
3662
  handler: async () => {
3655
3663
  },
3656
- requiresAuth: route.requiresAuth
3664
+ requiresAuth: route.requiresAuth,
3665
+ requiresPermission: route.requiresPermission,
3666
+ fga: route.fga
3657
3667
  };
3658
3668
  const routeHandler = async (c) => {
3659
3669
  const authError = await this.checkRouteAuth(serverRoute, {
@@ -3689,6 +3699,32 @@ var MastraServer = class extends MastraServer$1 {
3689
3699
  }
3690
3700
  }
3691
3701
  }
3702
+ let bodyParams = {};
3703
+ const contentType = c.req.header("content-type");
3704
+ if (contentType?.includes("application/json")) {
3705
+ try {
3706
+ const body = await c.req.raw.clone().json();
3707
+ if (body && typeof body === "object" && !Array.isArray(body)) {
3708
+ bodyParams = body;
3709
+ }
3710
+ } catch {
3711
+ bodyParams = {};
3712
+ }
3713
+ } else if (contentType?.includes("application/x-www-form-urlencoded") || contentType?.includes("multipart/form-data")) {
3714
+ try {
3715
+ bodyParams = Object.fromEntries(await c.req.raw.clone().formData());
3716
+ } catch {
3717
+ bodyParams = {};
3718
+ }
3719
+ }
3720
+ const fgaError = await checkRouteFGA(this.mastra, serverRoute, c.get("requestContext"), {
3721
+ ...c.req.param(),
3722
+ ...Object.fromEntries(new URL(c.req.url).searchParams.entries()),
3723
+ ...bodyParams
3724
+ });
3725
+ if (fgaError) {
3726
+ return c.json({ error: fgaError.error, message: fgaError.message }, fgaError.status);
3727
+ }
3692
3728
  const reqHeaders = {};
3693
3729
  c.req.raw.headers.forEach((v, k) => {
3694
3730
  reqHeaders[k] = v;