@mastra/fastify 0.0.0-studio-deploy-20260404182525 → 0.0.0-studio-cli-20260504022012
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 +576 -4
- package/dist/index.cjs +45 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -20
- package/dist/index.js.map +1 -1
- package/package.json +17 -17
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ declare module 'fastify' {
|
|
|
11
11
|
interface FastifyRequest {
|
|
12
12
|
mastra: Mastra;
|
|
13
13
|
requestContext: RequestContext;
|
|
14
|
-
|
|
14
|
+
registeredTools: ToolsInput;
|
|
15
15
|
abortSignal: AbortSignal;
|
|
16
16
|
taskStore: InMemoryTaskStore;
|
|
17
17
|
customRouteAuthConfig?: Map<string, boolean>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACtF,OAAO,EACL,YAAY,IAAI,gBAAgB,EAGjC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAsB,MAAM,SAAS,CAAC;AAExH,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAE,4BAA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E,YAAY,EAAE,MAAM,EAAE;QAAE,UAAU,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAyEtG,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAkC1F;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;IAyDxB,YAAY,CAChB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,cAAc,EACxB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAqIV,aAAa,CACjB,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,WAAW,EAClB,EAAE,MAAM,EAAE,WAAW,EAAE,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO,GAChD,OAAO,CAAC,IAAI,CAAC;IAwMV,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC;IA2F9C,yBAAyB,IAAI,IAAI;IA6BjC,sBAAsB,IAAI,IAAI;IAK9B,6BAA6B,IAAI,IAAI;CA+CtC"}
|
package/dist/index.js
CHANGED
|
@@ -339,7 +339,7 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
339
339
|
const requestContext = this.mergeRequestContext({ paramsRequestContext, bodyRequestContext });
|
|
340
340
|
request.requestContext = requestContext;
|
|
341
341
|
request.mastra = this.mastra;
|
|
342
|
-
request.
|
|
342
|
+
request.registeredTools = this.tools || {};
|
|
343
343
|
if (this.taskStore) {
|
|
344
344
|
request.taskStore = this.taskStore;
|
|
345
345
|
}
|
|
@@ -450,22 +450,26 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
450
450
|
},
|
|
451
451
|
limits: maxFileSize ? { fileSize: maxFileSize } : void 0
|
|
452
452
|
});
|
|
453
|
-
busboy.on(
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
453
|
+
busboy.on(
|
|
454
|
+
"file",
|
|
455
|
+
(fieldname, file, _filename, _encoding, _mimetype) => {
|
|
456
|
+
const chunks = [];
|
|
457
|
+
let limitExceeded = false;
|
|
458
|
+
file.on("data", (chunk) => {
|
|
459
|
+
chunks.push(chunk);
|
|
460
|
+
});
|
|
461
|
+
file.on("limit", () => {
|
|
462
|
+
limitExceeded = true;
|
|
463
|
+
file.resume();
|
|
464
|
+
reject(new Error(`File size limit exceeded${maxFileSize ? ` (max: ${maxFileSize} bytes)` : ""}`));
|
|
465
|
+
});
|
|
466
|
+
file.on("end", () => {
|
|
467
|
+
if (!limitExceeded) {
|
|
468
|
+
result[fieldname] = Buffer.concat(chunks);
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
);
|
|
469
473
|
busboy.on("field", (fieldname, value) => {
|
|
470
474
|
try {
|
|
471
475
|
result[fieldname] = JSON.parse(value);
|
|
@@ -484,6 +488,13 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
484
488
|
}
|
|
485
489
|
async sendResponse(route, reply, result, request, prefix) {
|
|
486
490
|
const resolvedPrefix = prefix ?? this.prefix ?? "";
|
|
491
|
+
if (result && typeof result === "object" && "__refreshHeaders" in result) {
|
|
492
|
+
const refreshHeaders = result.__refreshHeaders;
|
|
493
|
+
for (const [key, value] of Object.entries(refreshHeaders)) {
|
|
494
|
+
reply.header(key, value);
|
|
495
|
+
}
|
|
496
|
+
delete result.__refreshHeaders;
|
|
497
|
+
}
|
|
487
498
|
if (route.responseType === "json") {
|
|
488
499
|
await reply.send(result);
|
|
489
500
|
} else if (route.responseType === "stream") {
|
|
@@ -594,7 +605,14 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
594
605
|
buildAuthorizeContext: () => toWebRequest2(request)
|
|
595
606
|
});
|
|
596
607
|
if (authError) {
|
|
597
|
-
|
|
608
|
+
if (authError.headers) {
|
|
609
|
+
for (const [key, value] of Object.entries(authError.headers)) {
|
|
610
|
+
void reply.header(key, value);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
if (authError.error) {
|
|
614
|
+
return reply.status(authError.status).send({ error: authError.error });
|
|
615
|
+
}
|
|
598
616
|
}
|
|
599
617
|
const params = await this.getParams(route, request);
|
|
600
618
|
if (params.bodyParseError) {
|
|
@@ -660,7 +678,7 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
660
678
|
...typeof params.body === "object" ? params.body : {},
|
|
661
679
|
requestContext: request.requestContext,
|
|
662
680
|
mastra: this.mastra,
|
|
663
|
-
|
|
681
|
+
registeredTools: request.registeredTools,
|
|
664
682
|
taskStore: request.taskStore,
|
|
665
683
|
abortSignal: request.abortSignal,
|
|
666
684
|
routePrefix: prefix
|
|
@@ -751,7 +769,14 @@ var MastraServer = class extends MastraServer$1 {
|
|
|
751
769
|
buildAuthorizeContext: () => toWebRequest2(request)
|
|
752
770
|
});
|
|
753
771
|
if (authError) {
|
|
754
|
-
|
|
772
|
+
if (authError.headers) {
|
|
773
|
+
for (const [key, value] of Object.entries(authError.headers)) {
|
|
774
|
+
void reply.header(key, value);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
if (authError.error) {
|
|
778
|
+
return reply.status(authError.status).send({ error: authError.error });
|
|
779
|
+
}
|
|
755
780
|
}
|
|
756
781
|
const authConfig = this.mastra.getServer()?.auth;
|
|
757
782
|
if (authConfig) {
|