@nest-boot/mastra 0.0.0-stage → 8.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.
@@ -0,0 +1,351 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { ObservabilityStorageClickhouseVNext } from "@mastra/clickhouse";
14
+ import { Mastra } from "@mastra/core/mastra";
15
+ import { InMemoryStore, MastraCompositeStore } from "@mastra/core/storage";
16
+ import { BodyLimitMiddleware, JsonBodyMiddleware, MASTRA, MASTRA_OPTIONS, MastraExceptionFilter, MastraService, MastraThrottleGuard, RequestContextService, RequestTrackingInterceptor, RouteHandlerService, ShutdownService, StreamingInterceptor, TracingInterceptor, } from "@mastra/nestjs";
17
+ import { MastraStorageExporter, Observability, SensitiveDataFilter, } from "@mastra/observability";
18
+ import { PostgresStore } from "@mastra/pg";
19
+ import { Global, Inject, Module, RequestMethod, } from "@nestjs/common";
20
+ import { DiscoveryModule, ModulesContainer, RouterModule } from "@nestjs/core";
21
+ import { omit } from "lodash-es";
22
+ import { MastraController } from "./mastra.controller.js";
23
+ import { MastraManager } from "./mastra.manager.js";
24
+ import { ConfigurableModuleClass, MASTRA_MODULE_OPTIONS, normalizeMastraApiOptions, normalizeMastraStudioOptions, resolveMastraStudioBasePath, } from "./mastra.module-definition.js";
25
+ import { MastraStudioMiddleware } from "./mastra-studio.middleware.js";
26
+ const MASTRA_ROUTER_BINDING = Symbol("MASTRA_ROUTER_BINDING");
27
+ const POSTGRES_PROTOCOLS = new Set(["postgres:", "postgresql:"]);
28
+ const HTTP_PROTOCOLS = new Set(["http:", "https:"]);
29
+ /**
30
+ * Resolves a PostgreSQL connection string from `MASTRA_DATABASE_URL ?? DATABASE_URL`
31
+ * when its protocol is `postgres:` or `postgresql:`.
32
+ * @param mastraDatabaseUrl - Optional dedicated `MASTRA_DATABASE_URL` environment value
33
+ * @param databaseUrl - Fallback `DATABASE_URL` environment value
34
+ * @returns Trimmed PostgreSQL connection string, or `undefined` when absent or non-PostgreSQL
35
+ */
36
+ function resolvePostgresDatabaseUrl(mastraDatabaseUrl = process.env.MASTRA_DATABASE_URL, databaseUrl = process.env.DATABASE_URL) {
37
+ const trimmedMastraUrl = mastraDatabaseUrl?.trim();
38
+ const candidate = trimmedMastraUrl && trimmedMastraUrl.length > 0
39
+ ? trimmedMastraUrl
40
+ : databaseUrl?.trim();
41
+ if (!candidate) {
42
+ return undefined;
43
+ }
44
+ try {
45
+ const parsed = new URL(candidate);
46
+ return POSTGRES_PROTOCOLS.has(parsed.protocol) ? candidate : undefined;
47
+ }
48
+ catch {
49
+ return undefined;
50
+ }
51
+ }
52
+ /**
53
+ * Parses `MASTRA_CLICKHOUSE_URL` into connection options for `ObservabilityStorageClickhouseVNext`.
54
+ * Supports `http:`, `https:`, `clickhouse:`, and `clickhouses:` URLs with optional credentials,
55
+ * database pathname, and query parameters.
56
+ * @param clickhouseUrl - Raw `MASTRA_CLICKHOUSE_URL` environment value
57
+ * @returns Normalized ClickHouse URL and credentials, or `undefined` when absent or invalid
58
+ */
59
+ function resolveClickhouseConfig(clickhouseUrl = process.env.MASTRA_CLICKHOUSE_URL) {
60
+ const trimmed = clickhouseUrl?.trim();
61
+ if (!trimmed) {
62
+ return undefined;
63
+ }
64
+ try {
65
+ const normalizedInput = trimmed
66
+ .replace(/^clickhouse:\/\//i, "http://")
67
+ .replace(/^clickhouses:\/\//i, "https://");
68
+ const parsed = new URL(normalizedInput);
69
+ if (!HTTP_PROTOCOLS.has(parsed.protocol)) {
70
+ return undefined;
71
+ }
72
+ const username = parsed.username
73
+ ? decodeURIComponent(parsed.username)
74
+ : "default";
75
+ const password = parsed.password ? decodeURIComponent(parsed.password) : "";
76
+ parsed.username = "";
77
+ parsed.password = "";
78
+ return {
79
+ url: parsed.toString(),
80
+ username,
81
+ password,
82
+ };
83
+ }
84
+ catch {
85
+ return undefined;
86
+ }
87
+ }
88
+ /**
89
+ * Builds the default Mastra storage from `MASTRA_DATABASE_URL ?? DATABASE_URL` (PostgreSQL)
90
+ * and optional `MASTRA_CLICKHOUSE_URL` (ClickHouse vNext observability).
91
+ * Returns `undefined` when neither a PostgreSQL URL nor ClickHouse URL is configured.
92
+ * @returns Default `MastraCompositeStore` instance or `undefined`
93
+ */
94
+ function createDefaultMastraStorage() {
95
+ const connectionString = resolvePostgresDatabaseUrl();
96
+ const postgresStore = connectionString
97
+ ? new PostgresStore({
98
+ id: "mastra-storage",
99
+ connectionString,
100
+ schemaName: "mastra",
101
+ })
102
+ : undefined;
103
+ const clickhouseConfig = resolveClickhouseConfig();
104
+ const clickhouseObservability = clickhouseConfig
105
+ ? new ObservabilityStorageClickhouseVNext(clickhouseConfig)
106
+ : undefined;
107
+ if (postgresStore && clickhouseObservability) {
108
+ return new MastraCompositeStore({
109
+ id: "composite-storage",
110
+ default: postgresStore,
111
+ domains: {
112
+ observability: clickhouseObservability,
113
+ },
114
+ });
115
+ }
116
+ if (postgresStore) {
117
+ return postgresStore;
118
+ }
119
+ if (clickhouseObservability) {
120
+ return new MastraCompositeStore({
121
+ id: "composite-storage",
122
+ default: new InMemoryStore(),
123
+ domains: {
124
+ observability: clickhouseObservability,
125
+ },
126
+ });
127
+ }
128
+ return undefined;
129
+ }
130
+ /**
131
+ * Builds the default Mastra observability instance exporting traces to Mastra storage.
132
+ * @returns Default `Observability` instance
133
+ */
134
+ function createDefaultMastraObservability() {
135
+ return new Observability({
136
+ configs: {
137
+ default: {
138
+ serviceName: "mastra",
139
+ exporters: [new MastraStorageExporter()],
140
+ spanOutputProcessors: [new SensitiveDataFilter()],
141
+ },
142
+ },
143
+ });
144
+ }
145
+ /**
146
+ * Extracts `@mastra/core` constructor config from combined `MastraModuleOptions`
147
+ * and applies built-in PostgreSQL `storage` and `observability` defaults when omitted.
148
+ * @param options - Combined Mastra module options
149
+ * @returns Core `Mastra` constructor config
150
+ */
151
+ function extractMastraCoreConfig(options) {
152
+ if (options.server !== undefined) {
153
+ throw new Error("MastraModule does not support server configuration. Configure HTTP routes, authentication, middleware, and CORS through NestJS instead.");
154
+ }
155
+ if (typeof options.api === "object") {
156
+ for (const key of ["auth", "customRouteAuthConfig"]) {
157
+ if (options.api[key] !== undefined) {
158
+ throw new Error(`MastraModule does not support api.${key}. Configure authentication and custom routes through NestJS instead.`);
159
+ }
160
+ }
161
+ }
162
+ const mastraConfig = omit(options, ["server", "api", "studio"]);
163
+ const storage = mastraConfig.storage ?? createDefaultMastraStorage();
164
+ const observability = mastraConfig.observability ?? createDefaultMastraObservability();
165
+ return {
166
+ ...mastraConfig,
167
+ ...(storage ? { storage } : {}),
168
+ observability,
169
+ };
170
+ }
171
+ /**
172
+ * Registers Mastra Studio and API body-parsing middlewares according to resolved options.
173
+ * @param consumer - NestJS middleware consumer
174
+ * @param options - Resolved Mastra module options
175
+ * @param mountApiController - Whether `MastraController` is registered on the module
176
+ */
177
+ function configureMastraMiddlewares(consumer, options, mountApiController) {
178
+ const { enabled: apiEnabled, serverOptions } = normalizeMastraApiOptions(options.api);
179
+ const studioOptions = normalizeMastraStudioOptions(options.studio, apiEnabled);
180
+ if (studioOptions.enabled) {
181
+ const studioBasePath = resolveMastraStudioBasePath(serverOptions.prefix);
182
+ consumer.apply(MastraStudioMiddleware).forRoutes({
183
+ path: studioBasePath,
184
+ method: RequestMethod.GET,
185
+ }, {
186
+ path: `${studioBasePath}/{*path}`,
187
+ method: RequestMethod.GET,
188
+ });
189
+ }
190
+ if (mountApiController && apiEnabled) {
191
+ consumer
192
+ .apply(BodyLimitMiddleware, JsonBodyMiddleware)
193
+ .forRoutes(MastraController);
194
+ }
195
+ }
196
+ const MASTRA_SHARED_PROVIDERS = [
197
+ {
198
+ provide: MASTRA_MODULE_OPTIONS,
199
+ useValue: {},
200
+ },
201
+ {
202
+ provide: Mastra,
203
+ inject: [MASTRA_MODULE_OPTIONS],
204
+ useFactory: (options) => new Mastra(extractMastraCoreConfig(options)),
205
+ },
206
+ {
207
+ provide: MASTRA,
208
+ useExisting: Mastra,
209
+ },
210
+ {
211
+ provide: MASTRA_OPTIONS,
212
+ inject: [Mastra, MASTRA_MODULE_OPTIONS],
213
+ useFactory: (mastra, options) => ({
214
+ ...normalizeMastraApiOptions(options.api).serverOptions,
215
+ mastra,
216
+ // NestJS guards own authorization; disable the upstream server auth layer.
217
+ auth: { enabled: false },
218
+ }),
219
+ },
220
+ MastraService,
221
+ RouteHandlerService,
222
+ RequestContextService,
223
+ ShutdownService,
224
+ BodyLimitMiddleware,
225
+ JsonBodyMiddleware,
226
+ MastraThrottleGuard,
227
+ TracingInterceptor,
228
+ StreamingInterceptor,
229
+ RequestTrackingInterceptor,
230
+ MastraExceptionFilter,
231
+ MastraManager,
232
+ MastraStudioMiddleware,
233
+ ];
234
+ const MASTRA_SHARED_EXPORTS = [
235
+ MASTRA_MODULE_OPTIONS,
236
+ MASTRA,
237
+ Mastra,
238
+ MastraManager,
239
+ MastraService,
240
+ ];
241
+ /**
242
+ * Headless Mastra module used when `api` routes are explicitly disabled, keeping
243
+ * `Mastra`, `MastraManager` auto-discovery, and optional Studio middleware active
244
+ * without registering `MastraController`.
245
+ */
246
+ let MastraHeadlessModule = class MastraHeadlessModule {
247
+ options;
248
+ constructor(options) {
249
+ this.options = options;
250
+ }
251
+ configure(consumer) {
252
+ configureMastraMiddlewares(consumer, this.options, false);
253
+ }
254
+ };
255
+ MastraHeadlessModule = __decorate([
256
+ Global(),
257
+ Module({
258
+ imports: [DiscoveryModule],
259
+ providers: MASTRA_SHARED_PROVIDERS,
260
+ exports: MASTRA_SHARED_EXPORTS,
261
+ }),
262
+ __param(0, Inject(MASTRA_MODULE_OPTIONS)),
263
+ __metadata("design:paramtypes", [Object])
264
+ ], MastraHeadlessModule);
265
+ /**
266
+ * Global NestJS-native Mastra module.
267
+ *
268
+ * Reuses `@mastra/nestjs` services, interceptors, and filters with a local
269
+ * `MastraController` mounted at `api.prefix` (defaulting to `/api/mastra`),
270
+ * serves bundled Mastra Studio via middleware at `${prefix}/studio`, shares a
271
+ * single `Mastra` instance, and automatically discovers all singleton
272
+ * `BaseAgent` (and Mastra `Agent`) and `BaseWorkflow` (and Mastra `Workflow`)
273
+ * providers.
274
+ */
275
+ let MastraModule = class MastraModule extends ConfigurableModuleClass {
276
+ options;
277
+ constructor(options) {
278
+ super();
279
+ this.options = options;
280
+ }
281
+ /**
282
+ * Configures `MastraModule` synchronously. Skips registering `MastraController`
283
+ * when `options.api` is disabled (`false` or `{ enabled: false }`).
284
+ * @param options - Synchronous Mastra module options
285
+ * @returns Configured dynamic module
286
+ */
287
+ static forRoot(options) {
288
+ const dynamicModule = super.forRoot(options);
289
+ if (!normalizeMastraApiOptions(options.api).enabled) {
290
+ return {
291
+ ...dynamicModule,
292
+ module: MastraHeadlessModule,
293
+ };
294
+ }
295
+ return dynamicModule;
296
+ }
297
+ /**
298
+ * Configures `MastraModule` asynchronously. Pass `api: false` on the async
299
+ * options object to skip registering `MastraController` statically, or return
300
+ * `{ api: false }` from the factory to disable API handling at runtime.
301
+ * @param options - Asynchronous Mastra module options
302
+ * @returns Configured dynamic module
303
+ */
304
+ static forRootAsync(options) {
305
+ const { api, ...asyncOptions } = options;
306
+ const dynamicModule = super.forRootAsync(asyncOptions);
307
+ if (api === false) {
308
+ return {
309
+ ...dynamicModule,
310
+ module: MastraHeadlessModule,
311
+ };
312
+ }
313
+ return dynamicModule;
314
+ }
315
+ /**
316
+ * Mounts Mastra Studio middleware at `${prefix}/studio` and Mastra JSON/body-limit
317
+ * middleware scoped to `MastraController`.
318
+ * @param consumer - NestJS middleware consumer
319
+ */
320
+ configure(consumer) {
321
+ configureMastraMiddlewares(consumer, this.options, true);
322
+ }
323
+ };
324
+ MastraModule = __decorate([
325
+ Global(),
326
+ Module({
327
+ imports: [DiscoveryModule],
328
+ controllers: [MastraController],
329
+ providers: [
330
+ ...MASTRA_SHARED_PROVIDERS,
331
+ {
332
+ provide: MASTRA_ROUTER_BINDING,
333
+ inject: [ModulesContainer, MASTRA_MODULE_OPTIONS],
334
+ useFactory: (modulesContainer, options) => {
335
+ const { serverOptions } = normalizeMastraApiOptions(options.api);
336
+ return new RouterModule(modulesContainer, [
337
+ {
338
+ path: serverOptions.prefix,
339
+ module: MastraModule,
340
+ },
341
+ ]);
342
+ },
343
+ },
344
+ ],
345
+ exports: MASTRA_SHARED_EXPORTS,
346
+ }),
347
+ __param(0, Inject(MASTRA_MODULE_OPTIONS)),
348
+ __metadata("design:paramtypes", [Object])
349
+ ], MastraModule);
350
+ export { MastraModule };
351
+ //# sourceMappingURL=mastra.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mastra.module.js","sourceRoot":"","sources":["../src/mastra.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAA+B,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,MAAM,EACN,cAAc,EACd,qBAAqB,EAErB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EACnB,eAAe,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Y,CAC1B,OAAiC;QAEjC,MAAM,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,OAAO,CAAC;QACzC,MAAM,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACvD,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;YAClB,OAAO;gBACL,GAAG,aAAa;gBAChB,MAAM,EAAE,oBAAoB;aAC7B,CAAC;QACJ,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,QAA4B;QACpC,0BAA0B,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AAzDY,YAAY;IAzBxB,MAAM,EAAE;IACR,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,eAAe,CAAC;QAC1B,WAAW,EAAE,CAAC,gBAAgB,CAAC;QAC/B,SAAS,EAAE;YACT,GAAG,uBAAuB;YAC1B;gBACE,OAAO,EAAE,qBAAqB;gBAC9B,MAAM,EAAE,CAAC,gBAAgB,EAAE,qBAAqB,CAAC;gBACjD,UAAU,EAAE,CACV,gBAAkC,EAClC,OAA4B,EAC5B,EAAE;oBACF,MAAM,EAAE,aAAa,EAAE,GAAG,yBAAyB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;oBACjE,OAAO,IAAI,YAAY,CAAC,gBAAgB,EAAE;wBACxC;4BACE,IAAI,EAAE,aAAa,CAAC,MAAM;4BAC1B,MAAM,EAAE,YAAY;yBACrB;qBACF,CAAC,CAAC;gBACL,CAAC;aACF;SACF;QACD,OAAO,EAAE,qBAAqB;KAC/B,CAAC;IAMG,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;;GALrB,YAAY,CAyDxB"}
package/package.json CHANGED
@@ -1,6 +1,106 @@
1
1
  {
2
2
  "name": "@nest-boot/mastra",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "8.0.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/nest-boot/nest-boot.git",
7
+ "directory": "packages/mastra"
8
+ },
9
+ "description": "NestJS-native Mastra integration with DI auto-discovery, embedded Studio, auth protection, and PostgreSQL/ClickHouse storage",
10
+ "author": {
11
+ "name": "Xudong Huang",
12
+ "email": "me@huangxudong.com",
13
+ "url": "https://www.huangxudong.com/"
14
+ },
15
+ "homepage": "",
16
+ "license": "MIT",
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "directories": {
20
+ "lib": "dist"
21
+ },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "dependencies": {
26
+ "@mastra/clickhouse": "^1.30.1",
27
+ "@mastra/deployer": "^1.85.0",
28
+ "@mastra/nestjs": "^0.3.2",
29
+ "@mastra/observability": "^1.24.2",
30
+ "@mastra/pg": "^1.37.0",
31
+ "lodash-es": "^4.18.1"
32
+ },
33
+ "peerDependencies": {
34
+ "@mastra/core": "^1.84.0",
35
+ "@nestjs/common": "^12.0.0",
36
+ "@nestjs/core": "^12.0.0",
37
+ "express": "^5.0.0",
38
+ "mastra": "^1.40.1",
39
+ "reflect-metadata": "^0.2.2",
40
+ "rxjs": "^7.0.0",
41
+ "zod": "^4.0.0",
42
+ "@nest-boot/auth": "^8.5.0"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "mastra": {
46
+ "optional": true
47
+ }
48
+ },
49
+ "devDependencies": {
50
+ "@mastra/core": "^1.84.0",
51
+ "@nestjs/common": "^12.0.1",
52
+ "@nestjs/core": "^12.0.1",
53
+ "@nestjs/platform-express": "^12.1.2",
54
+ "@nestjs/testing": "^12.0.1",
55
+ "@types/express": "^5.0.6",
56
+ "@types/lodash-es": "^4.17.12",
57
+ "@types/node": "^24.0.0",
58
+ "@vitest/coverage-v8": "^4.1.11",
59
+ "eslint": "^9.39.3",
60
+ "express": "^5.3.0",
61
+ "mastra": "^1.40.1",
62
+ "reflect-metadata": "^0.2.2",
63
+ "rxjs": "^7.8.2",
64
+ "typescript": "^6.0.3",
65
+ "vite-tsconfig-paths": "^5.1.4",
66
+ "vitest": "^4.1.11",
67
+ "zod": "^4.3.6",
68
+ "@nest-boot/auth": "^8.5.0",
69
+ "@nest-boot/eslint-config": "^8.1.1",
70
+ "@nest-boot/eslint-plugin": "^8.2.0",
71
+ "@nest-boot/tsconfig": "^8.0.0"
72
+ },
73
+ "publishConfig": {
74
+ "access": "public"
75
+ },
76
+ "lint-staged": {
77
+ "*.ts": [
78
+ "prettier --write",
79
+ "eslint --fix"
80
+ ]
81
+ },
82
+ "type": "module",
83
+ "engines": {
84
+ "node": ">=24.21.0"
85
+ },
86
+ "exports": {
87
+ ".": {
88
+ "types": "./dist/index.d.ts",
89
+ "import": "./dist/index.js"
90
+ },
91
+ "./package.json": "./package.json"
92
+ },
93
+ "scripts": {
94
+ "build": "tsc -p tsconfig.build.json",
95
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
96
+ "dev": "tsc -w -p tsconfig.build.json",
97
+ "lint": "eslint \"{src,test}/**/*.ts\"",
98
+ "lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
99
+ "test": "pnpm typecheck && vitest run",
100
+ "test:cov": "pnpm typecheck && vitest run --coverage",
101
+ "test:watch": "vitest",
102
+ "typecheck": "tsc --noEmit",
103
+ "test:debug": "vitest --inspect-brk --no-file-parallelism",
104
+ "test:e2e": "pnpm typecheck && vitest run --config ./vitest.config.e2e.ts --coverage"
105
+ }
6
106
  }