@mastra/elysia 0.0.0
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 +44 -0
- package/dist/__tests__/helpers.d.ts +12 -0
- package/dist/__tests__/helpers.d.ts.map +1 -0
- package/dist/auth-middleware.d.ts +7 -0
- package/dist/auth-middleware.d.ts.map +1 -0
- package/dist/helper.d.ts +60 -0
- package/dist/helper.d.ts.map +1 -0
- package/dist/index.cjs +822 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +818 -0
- package/dist/index.js.map +1 -0
- package/package.json +76 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @mastra/elysia
|
|
2
|
+
|
|
3
|
+
## 0.1.0-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`48ef1f1`](https://github.com/mastra-ai/mastra/commit/48ef1f1d24eedafbb07f64e659a81b52b67b8bf6), [`63796ba`](https://github.com/mastra-ai/mastra/commit/63796ba0fda60253be17535e68f6bbbf1e6ffa09), [`3c19dce`](https://github.com/mastra-ai/mastra/commit/3c19dcef8e73062a80627a4927eae3ec11145afd)]:
|
|
8
|
+
- @mastra/core@1.62.0-alpha.12
|
|
9
|
+
- @mastra/server@1.62.0-alpha.12
|
|
10
|
+
|
|
11
|
+
## 0.1.0-alpha.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`4ff3ee2`](https://github.com/mastra-ai/mastra/commit/4ff3ee2bff7ed07528b4817f8f49639031c72a4d), [`c24754c`](https://github.com/mastra-ai/mastra/commit/c24754c1fb6fe144e5051e536e98c8a18b0214ac), [`45dd6ee`](https://github.com/mastra-ai/mastra/commit/45dd6ee089bd7df0d0c98a10098e483fd388e04a), [`32d3583`](https://github.com/mastra-ai/mastra/commit/32d358332cb8ac2306b83b73cf3536e74dbd435e), [`aca2869`](https://github.com/mastra-ai/mastra/commit/aca2869b2031982f3c4a2f52525c9be7cf123ef8)]:
|
|
16
|
+
- @mastra/core@1.62.0-alpha.11
|
|
17
|
+
- @mastra/server@1.62.0-alpha.11
|
|
18
|
+
|
|
19
|
+
## 0.1.0-alpha.0
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- Added an Elysia server adapter. Use the new @mastra/elysia package to run a Mastra server inside an Elysia app. ([#22274](https://github.com/mastra-ai/mastra/pull/22274))
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { Elysia } from 'elysia';
|
|
27
|
+
import { MastraServer } from '@mastra/elysia';
|
|
28
|
+
import { mastra } from './mastra';
|
|
29
|
+
|
|
30
|
+
const app = new Elysia();
|
|
31
|
+
const server = new MastraServer({ app, mastra });
|
|
32
|
+
|
|
33
|
+
await server.init();
|
|
34
|
+
|
|
35
|
+
app.listen(4111);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Added the `convertCustomRoutesToOpenAPIPaths` export to `@mastra/server/server-adapter` so server adapters can include custom API routes in generated OpenAPI documents. ([#22274](https://github.com/mastra-ai/mastra/pull/22274))
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [[`b05f486`](https://github.com/mastra-ai/mastra/commit/b05f48612984d5fe2447ea2d6cdd5c604d285b97), [`7960688`](https://github.com/mastra-ai/mastra/commit/7960688828e04eaf3106e34f7758fa580257eef6), [`2848a9f`](https://github.com/mastra-ai/mastra/commit/2848a9f4c89fa03c34e94793929d14640117d5f6), [`2848a9f`](https://github.com/mastra-ai/mastra/commit/2848a9f4c89fa03c34e94793929d14640117d5f6)]:
|
|
43
|
+
- @mastra/core@1.62.0-alpha.10
|
|
44
|
+
- @mastra/server@1.62.0-alpha.10
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Server } from 'node:http';
|
|
2
|
+
import type Elysia from 'elysia';
|
|
3
|
+
/**
|
|
4
|
+
* Starts a real Node HTTP server that delegates requests to an Elysia app's fetch method.
|
|
5
|
+
* This is needed for tests that use `fetch()` directly (multipart, OpenAPI, custom routes, MCP transport).
|
|
6
|
+
*/
|
|
7
|
+
export declare function startElysiaServer(app: Elysia): Promise<{
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
cleanup: () => Promise<void>;
|
|
10
|
+
server: Server;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/__tests__/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAuB,MAAM,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAiFD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Mastra } from '@mastra/core/mastra';
|
|
2
|
+
export interface ElysiaAuthMiddlewareOptions {
|
|
3
|
+
mastra: Mastra;
|
|
4
|
+
requiresAuth?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function createAuthMiddleware({ mastra, requiresAuth, }: ElysiaAuthMiddlewareOptions): (ctx: any) => Promise<globalThis.Response | void>;
|
|
7
|
+
//# sourceMappingURL=auth-middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-middleware.d.ts","sourceRoot":"","sources":["../src/auth-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,YAAmB,GACpB,EAAE,2BAA2B,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAC,CA8CjF"}
|
package/dist/helper.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { MastraServer } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get OpenAPI documentation from a MastraServer instance, formatted for Elysia's openapi plugin.
|
|
4
|
+
*
|
|
5
|
+
* This function:
|
|
6
|
+
* - Extracts all Mastra routes with their Zod schemas
|
|
7
|
+
* - Converts them to OpenAPI 3.1.0 format
|
|
8
|
+
* - Merges custom routes if registered
|
|
9
|
+
* - Applies the configured route prefix to all paths
|
|
10
|
+
* - Caches the result for performance
|
|
11
|
+
*
|
|
12
|
+
* @param server - The MastraServer instance (must be initialized with init())
|
|
13
|
+
* @param options - Optional configuration for OpenAPI metadata
|
|
14
|
+
* @returns OpenAPI documentation with paths, components, and info
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { getMastraOpenAPIDoc } from '@mastra/elysia';
|
|
19
|
+
*
|
|
20
|
+
* const srv = new MastraServer({ mastra, app, prefix: '/api' });
|
|
21
|
+
* await srv.init();
|
|
22
|
+
*
|
|
23
|
+
* const openAPIDoc = getMastraOpenAPIDoc(srv, {
|
|
24
|
+
* title: 'My Mastra API',
|
|
25
|
+
* version: '1.0.0',
|
|
26
|
+
* description: 'API with weather agent'
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* app.use(openapi({
|
|
30
|
+
* documentation: {
|
|
31
|
+
* info: openAPIDoc.info,
|
|
32
|
+
* paths: openAPIDoc.paths,
|
|
33
|
+
* components: openAPIDoc.components
|
|
34
|
+
* }
|
|
35
|
+
* }));
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function getMastraOpenAPIDoc(server: MastraServer, options?: {
|
|
39
|
+
title?: string;
|
|
40
|
+
version?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
clearCache?: boolean;
|
|
43
|
+
}): {
|
|
44
|
+
paths: Record<string, any>;
|
|
45
|
+
components?: Record<string, any>;
|
|
46
|
+
info: {
|
|
47
|
+
title: string;
|
|
48
|
+
version: string;
|
|
49
|
+
description?: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Clear the OpenAPI documentation cache.
|
|
54
|
+
* Call this if routes are added dynamically after initialization.
|
|
55
|
+
*
|
|
56
|
+
* `@param` server - The MastraServer instance to clear cache for.
|
|
57
|
+
* Note: WeakMap does not support clearing all entries. Pass the specific server instance whose cache should be invalidated.
|
|
58
|
+
*/
|
|
59
|
+
export declare function clearMastraOpenAPICache(server?: MastraServer): void;
|
|
60
|
+
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAe5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE;IACR,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GACA;IACD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAChE,CA8DA;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAKnE"}
|