@mastra/deployer 1.83.0-alpha.8 → 1.83.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/dist/_types/{@mastra_hono@1.7.25-alpha.8 → @mastra_hono@1.7.25}/dist/index.d.ts +2 -0
- package/dist/{analyze-DO5iGgpf.js → analyze-BaYUEglS.js} +67 -20
- package/dist/analyze-BaYUEglS.js.map +1 -0
- package/dist/{analyze-BBFIIBmH.cjs → analyze-UIkyk9Qr.cjs} +66 -19
- package/dist/analyze-UIkyk9Qr.cjs.map +1 -0
- package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
- package/dist/build/analyze/externals.d.ts +2 -0
- package/dist/build/analyze/externals.d.ts.map +1 -1
- package/dist/build/analyze.cjs +1 -1
- package/dist/build/analyze.d.ts.map +1 -1
- package/dist/build/analyze.js +1 -1
- package/dist/build/bundler.cjs +1 -1
- package/dist/build/bundler.js +1 -1
- package/dist/build/bundlerOptions.d.ts +1 -1
- package/dist/build/deployer.d.ts +1 -1
- package/dist/build/index.cjs +4 -4
- package/dist/build/index.js +4 -4
- package/dist/build/package-info.d.ts +6 -0
- package/dist/build/package-info.d.ts.map +1 -1
- package/dist/{build-DH0yT1Zp.cjs → build-BNbmUARF.cjs} +4 -4
- package/dist/{build-DH0yT1Zp.cjs.map → build-BNbmUARF.cjs.map} +1 -1
- package/dist/{build-AGyF63xq.js → build-BmIjWY26.js} +4 -4
- package/dist/{build-AGyF63xq.js.map → build-BmIjWY26.js.map} +1 -1
- package/dist/bundler/index.cjs +1 -1
- package/dist/bundler/index.d.ts +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/{bundler-BZ4fSyJZ.cjs → bundler-B85b7ZGn.cjs} +26 -1
- package/dist/bundler-B85b7ZGn.cjs.map +1 -0
- package/dist/{bundler-CRzGd7dU.cjs → bundler-BpXhdDyV.cjs} +4 -4
- package/dist/{bundler-CRzGd7dU.cjs.map → bundler-BpXhdDyV.cjs.map} +1 -1
- package/dist/{bundler-BadvdlF2.js → bundler-CtCtxgyj.js} +4 -4
- package/dist/{bundler-BadvdlF2.js.map → bundler-CtCtxgyj.js.map} +1 -1
- package/dist/{bundler-DSGZrLqs.js → bundler-DMIpMpLE.js} +21 -2
- package/dist/bundler-DMIpMpLE.js.map +1 -0
- package/dist/{bundlerOptions-DUh9CO6S.js → bundlerOptions-B8nx-_mx.js} +2 -2
- package/dist/{bundlerOptions-DUh9CO6S.js.map → bundlerOptions-B8nx-_mx.js.map} +1 -1
- package/dist/{bundlerOptions-Z4D-MNeR.cjs → bundlerOptions-C_YYCV7O.cjs} +2 -2
- package/dist/{bundlerOptions-Z4D-MNeR.cjs.map → bundlerOptions-C_YYCV7O.cjs.map} +1 -1
- package/dist/deploy/base.d.ts +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/server/index.cjs +32 -41
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +32 -41
- package/dist/server/index.js.map +1 -1
- package/dist/services/deps.d.ts +1 -1
- package/package.json +10 -10
- package/dist/analyze-BBFIIBmH.cjs.map +0 -1
- package/dist/analyze-DO5iGgpf.js.map +0 -1
- package/dist/bundler-BZ4fSyJZ.cjs.map +0 -1
- package/dist/bundler-DSGZrLqs.js.map +0 -1
- /package/dist/_types/{@internal_deployer@0.0.1 → @internal_deployer@0.0.2}/dist/_types/@internal_core@0.1.4/dist/index-Diz1p9N7.d.ts +0 -0
- /package/dist/_types/{@internal_deployer@0.0.1 → @internal_deployer@0.0.2}/dist/_types/@internal_core@0.1.4/dist/logger/index.d.ts +0 -0
- /package/dist/_types/{@internal_deployer@0.0.1 → @internal_deployer@0.0.2}/dist/bundler.d.ts +0 -0
- /package/dist/_types/{@internal_deployer@0.0.1 → @internal_deployer@0.0.2}/dist/deployer.d.ts +0 -0
- /package/dist/_types/{@internal_deployer@0.0.1 → @internal_deployer@0.0.2}/dist/index.d.ts +0 -0
- /package/dist/_types/{@internal_deployer@0.0.1 → @internal_deployer@0.0.2}/package.json +0 -0
- /package/dist/_types/{@mastra_hono@1.7.25-alpha.8 → @mastra_hono@1.7.25}/dist/auth-middleware.d.ts +0 -0
- /package/dist/_types/{@mastra_hono@1.7.25-alpha.8 → @mastra_hono@1.7.25}/dist/browser-stream/index.d.ts +0 -0
- /package/dist/_types/{@mastra_hono@1.7.25-alpha.8 → @mastra_hono@1.7.25}/package.json +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Bc0pwXKd.cjs");
|
|
2
|
-
const require_bundler = require("./bundler-
|
|
2
|
+
const require_bundler = require("./bundler-B85b7ZGn.cjs");
|
|
3
3
|
const require_utils = require("./utils-CDNA_ewa.cjs");
|
|
4
4
|
let fs = require("fs");
|
|
5
5
|
let path = require("path");
|
|
@@ -237,4 +237,4 @@ Object.defineProperty(exports, "getBundlerOptions", {
|
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
-
//# sourceMappingURL=bundlerOptions-
|
|
240
|
+
//# sourceMappingURL=bundlerOptions-C_YYCV7O.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundlerOptions-Z4D-MNeR.cjs","names":["t","transformAsync","t","transformAsync","sep","pkg","dirname","realpathSync","isAbsolute","nodeResolve","getNodeResolveOptions","isBareModuleSpecifier","pathToFileURL","tsConfigPaths","esbuild","optimizeLodashImports","commonjs","json"],"sources":["../src/build/babel/remove-all-options-except.ts","../src/build/plugins/remove-all-except.ts","../src/build/babel/remove-non-referenced-nodes.ts","../src/build/plugins/remove-unused-references.ts","../src/build/shared/extract-mastra-option.ts","../src/build/bundlerOptions.ts"],"sourcesContent":["import { types as t } from '@babel/core';\nimport type { NodePath, PluginObject, types } from '@babel/core';\nimport type { IMastraLogger } from '@internal/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\n\nexport function removeAllOptionsFromMastraExcept(\n result: { hasCustomConfig: boolean },\n option: keyof MastraConfig,\n logger?: IMastraLogger,\n): PluginObject {\n return {\n name: 'remove-all-except-' + option + '-config',\n visitor: {\n ExportNamedDeclaration: {\n // remove all exports, but keep the underlying declarations — the\n // extracted option may reference them (e.g. `export const deployer = ...`\n // used as `new Mastra({ deployer })`). Unreferenced declarations are\n // dropped by the cleanup pass afterwards.\n exit(path) {\n if (path.node.declaration) {\n const [declaration] = path.replaceWith(path.node.declaration);\n // Already traversed — don't requeue, or the NewExpression visitor\n // would append the extracted export a second time.\n declaration.skip();\n } else {\n path.remove();\n }\n },\n },\n\n NewExpression(path, state) {\n // is a variable declaration\n const varDeclaratorPath = path.findParent(path => t.isVariableDeclarator(path.node));\n if (!varDeclaratorPath) {\n return;\n }\n\n const parentNode = path.parentPath.node;\n // check if it's a const of mastra\n if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== 'mastra') {\n return;\n }\n\n let mastraArgs = t.objectExpression([]);\n if (t.isObjectExpression(path.node.arguments[0])) {\n mastraArgs = path.node.arguments[0];\n }\n\n // Find the config property, skipping SpreadElement nodes\n let configProperty = mastraArgs.properties.find(\n prop => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === option,\n );\n let configValue: types.Expression = t.objectExpression([]);\n\n const programPath = path.scope.getProgramParent().path as NodePath<types.Program> | undefined;\n if (!programPath) {\n return;\n }\n\n if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {\n result.hasCustomConfig = true;\n configValue = configProperty.value;\n\n if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {\n const configBinding = state.file.scope.getBinding(option)!;\n\n if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {\n const id = path.scope.generateUidIdentifier(option);\n\n configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init!));\n configValue = id;\n }\n }\n }\n\n // add the deployer export\n const exportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), configValue)]),\n [],\n );\n\n programPath.node.body.push(exportDeclaration);\n },\n\n Program: {\n exit(path) {\n // Add a fallback export if no mastra configuration was found\n const hasExport = path.node.body.some(\n node => node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration',\n );\n\n if (!hasExport) {\n if (logger) {\n logger.warn('Mastra config could not be extracted', {\n option,\n details:\n 'Please make sure your entry file looks like this:\\nexport const mastra = new Mastra({\\n <option>: <value>\\n})',\n });\n }\n\n const fallbackExportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),\n [],\n );\n path.node.body.push(fallbackExportDeclaration);\n }\n },\n },\n },\n } satisfies PluginObject;\n}\n","import { transformAsync } from '@babel/core';\nimport type { IMastraLogger } from '@internal/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport type { Plugin, SourceMapInput } from 'rollup';\nimport { removeAllOptionsFromMastraExcept } from '../babel/remove-all-options-except';\n\nexport function removeAllOptionsFromMastraExceptPlugin(\n mastraEntry: string,\n name: keyof MastraConfig,\n result: { hasCustomConfig: boolean },\n options?: { sourcemap?: boolean; logger?: IMastraLogger },\n): Plugin {\n return {\n name: `remove-${name}`,\n transform(code, id) {\n if (id !== mastraEntry) {\n return;\n }\n\n return transformAsync(code, {\n babelrc: false,\n configFile: false,\n filename: id,\n plugins: [() => removeAllOptionsFromMastraExcept(result, name, options?.logger)],\n sourceMaps: options?.sourcemap,\n }).then(result => ({\n code: result!.code!,\n map: result!.map! as SourceMapInput,\n }));\n },\n } satisfies Plugin;\n}\n","import { types as t } from '@babel/core';\nimport type { PluginObject } from '@babel/core';\n\nexport function removeNonReferencedNodes() {\n return {\n name: 'remove-non-referenced-nodes',\n visitor: {\n Program(path) {\n // Get the scope information\n const scope = path.scope;\n\n // Filter body to keep only referenced nodes\n const currentBody = path.get('body');\n const filteredBody = currentBody.filter(childPath => {\n if (childPath.isExportDeclaration()) {\n return true;\n }\n\n // For variable declarations, check if any declared variables are referenced\n if (childPath.isVariableDeclaration()) {\n return childPath.node.declarations.some(decl => {\n if (!t.isIdentifier(decl.id)) {\n return false;\n }\n\n const name = decl.id.name;\n const binding = scope.getBinding(name);\n // Keep if it has references or is exported\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // For function/class declarations, check if they're referenced\n if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {\n if (!t.isIdentifier(childPath.node.id)) {\n return false;\n }\n\n const name = childPath.node.id.name;\n const binding = scope.getBinding(name);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n }\n\n // For imports, check if any imported items are referenced\n if (childPath.isImportDeclaration()) {\n return childPath.node.specifiers.some(specifier => {\n const importedName = specifier.local.name;\n const binding = scope.getBinding(importedName);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // Default to keeping other node types\n return false;\n });\n\n // Replace the program body with filtered nodes\n path.set(\n 'body',\n filteredBody.map(p => p.node),\n );\n },\n },\n } as PluginObject;\n}\n","import { transformAsync } from '@babel/core';\nimport { removeNonReferencedNodes } from '../babel/remove-non-referenced-nodes';\n\nexport async function recursiveRemoveNonReferencedNodes(code: string): Promise<{ code: string; map: any }> {\n const result = await transformAsync(code, {\n babelrc: false,\n configFile: false,\n plugins: [removeNonReferencedNodes],\n });\n\n // keep looping until the code is not changed\n if (result && result.code! !== code) {\n return recursiveRemoveNonReferencedNodes(result!.code!);\n }\n\n return {\n code: result!.code!,\n map: result!.map!,\n };\n}\n","import { realpathSync } from 'node:fs';\nimport { dirname, isAbsolute, sep } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { IMastraLogger } from '@internal/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport * as pkg from 'empathic/package';\nimport { rollup } from 'rollup';\nimport type { Plugin, RollupOutput } from 'rollup';\nimport { esbuild } from '../plugins/esbuild';\nimport { removeAllOptionsFromMastraExceptPlugin } from '../plugins/remove-all-except';\nimport { recursiveRemoveNonReferencedNodes } from '../plugins/remove-unused-references';\nimport { tsConfigPaths } from '../plugins/tsconfig-paths';\nimport { getNodeResolveOptions, isBareModuleSpecifier } from '../utils';\n\nconst TS_SOURCE = /\\.tsx?$/;\nconst NODE_MODULES = `${sep}node_modules${sep}`;\n\n/**\n * Packages outside node_modules, such as workspace packages, may ship raw TypeScript (e.g. `exports` pointing to\n * `src/index.ts`), which Node cannot load from the extracted config. Inline those so esbuild transpiles them. Bare\n * imports made from inlined sources stay external but are pinned to the file they resolve to from that source: the\n * extracted config lives in `.mastra/output` and can't see the package's own `node_modules` (e.g. pnpm isolated\n * installs). The app's own imports keep resolving by name.\n */\nfunction typescriptSourcesResolver(entryFile: string): Plugin {\n const appPackageJson = pkg.up({ cwd: dirname(entryFile) });\n const appDir = appPackageJson ? dirname(appPackageJson) : dirname(entryFile);\n // App files keep the entry's path, files resolved by node-resolve are real paths\n const appRoots = [appDir + sep, realpathSync(appDir) + sep];\n const isInlinedSource = (file: string) =>\n isAbsolute(file) && !file.includes(NODE_MODULES) && !appRoots.some(root => file.startsWith(root));\n\n const resolver = nodeResolve({\n ...getNodeResolveOptions('node'),\n extensions: ['.mjs', '.js', '.json', '.node', '.ts', '.tsx'],\n });\n const resolveHook = resolver.resolveId!;\n const resolve = typeof resolveHook === 'function' ? resolveHook : resolveHook.handler;\n\n return {\n ...resolver,\n name: 'typescript-sources-resolver',\n async resolveId(id, importer, options) {\n if (!importer || !isBareModuleSpecifier(id)) {\n return null;\n }\n\n // node-resolve passes each result back through `this.resolve`, and the commonjs plugin's resolveId loads every\n // `.js` result to check whether it is CommonJS. With the live context that loads and transforms every installed\n // package reachable from a surviving import, recursively, though all of them end up external.\n const context = Object.create(this, { resolve: { value: async () => null } });\n const resolved = await resolve.call(context, id, importer, options);\n if (!resolved || typeof resolved !== 'object' || resolved.external) {\n return null;\n }\n\n if (TS_SOURCE.test(resolved.id) && !resolved.id.includes(NODE_MODULES)) {\n return resolved.id;\n }\n\n return isInlinedSource(importer) ? { id: pathToFileURL(resolved.id).href, external: true } : null;\n },\n };\n}\n\nexport function extractMastraOptionBundler(\n name: keyof MastraConfig,\n entryFile: string,\n result: {\n hasCustomConfig: boolean;\n },\n logger?: IMastraLogger,\n) {\n return rollup({\n logLevel: 'silent',\n input: {\n [`${name}-config`]: entryFile,\n },\n treeshake: 'smallest',\n plugins: [\n tsConfigPaths(),\n typescriptSourcesResolver(entryFile),\n // transpile typescript to something we understand\n esbuild(),\n optimizeLodashImports({\n include: '**/*.{js,ts,mjs,cjs}',\n }),\n commonjs({\n extensions: ['.js', '.ts'],\n strictRequires: 'strict',\n transformMixedEsModules: true,\n ignoreTryCatch: false,\n }),\n json(),\n removeAllOptionsFromMastraExceptPlugin(entryFile, name, result, { logger }),\n // let esbuild remove all unused imports\n esbuild(),\n {\n name: 'cleanup',\n transform(code, id) {\n if (id !== entryFile) {\n return;\n }\n\n return recursiveRemoveNonReferencedNodes(code);\n },\n },\n // let esbuild remove it once more\n esbuild(),\n ],\n });\n}\n\nexport async function extractMastraOption<T extends keyof MastraConfig>(\n name: T,\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<{\n bundleOutput: RollupOutput;\n getConfig: () => Promise<MastraConfig[T]>;\n} | null> {\n const result = {\n hasCustomConfig: false,\n };\n\n const bundler = await extractMastraOptionBundler(name, entryFile, result, logger);\n\n const output = await bundler.write({\n dir: outputDir,\n format: 'es',\n entryFileNames: '[name].mjs',\n // Chunks are written outside any package with \"type\": \"module\", so a `.js` chunk would be loaded as CommonJS\n // (#28491). The hash keeps them distinct from the main bundle's chunks in `.mastra/output`.\n chunkFileNames: '[name]-[hash].mjs',\n });\n\n if (result.hasCustomConfig) {\n const configPath = `${outputDir}/${name}-config.mjs`;\n\n return {\n bundleOutput: output,\n getConfig: () => import(pathToFileURL(configPath).href).then(m => m[name] as MastraConfig[T]),\n };\n }\n\n return null;\n}\n","import type { IMastraLogger } from '@internal/core/logger';\nimport type { BundlerConfig } from '@internal/deployer';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getBundlerOptionsBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('bundler', entryFile, result);\n}\n\nexport async function getBundlerOptions(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<BundlerConfig | undefined | null> {\n const result = await extractMastraOption('bundler', entryFile, outputDir, logger);\n\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,SAAgB,iCACd,QACA,QACA,QACc;CACd,OAAO;EACL,MAAM,uBAAuB,SAAS;EACtC,SAAS;GACP,wBAAwB,EAKtB,KAAK,MAAM;IACT,IAAI,KAAK,KAAK,aAAa;KACzB,MAAM,CAAC,eAAe,KAAK,YAAY,KAAK,KAAK,WAAW;KAG5D,YAAY,KAAK;IACnB,OACE,KAAK,OAAO;GAEhB,EACF;GAEA,cAAc,MAAM,OAAO;IAGzB,IAAI,CADsB,KAAK,YAAW,SAAQA,YAAAA,MAAE,qBAAqB,KAAK,IAAI,CAC7D,GACnB;IAGF,MAAM,aAAa,KAAK,WAAW;IAEnC,IAAI,CAACA,YAAAA,MAAE,qBAAqB,UAAU,KAAK,CAACA,YAAAA,MAAE,aAAa,WAAW,EAAE,KAAK,WAAW,GAAG,SAAS,UAClG;IAGF,IAAI,aAAaA,YAAAA,MAAE,iBAAiB,CAAC,CAAC;IACtC,IAAIA,YAAAA,MAAE,mBAAmB,KAAK,KAAK,UAAU,EAAE,GAC7C,aAAa,KAAK,KAAK,UAAU;IAInC,IAAI,iBAAiB,WA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AAM;IACN,UAAU,MAAM,IAAI;KAClB,IAAI,OAAO,WACT;KAGF,OAAO,kCAAkC,IAAI;IAC/C;GACF;GAEAA,gBAAAA,QAAQ;EACV;CACF,CAAC;AACH;AAEA,eAAsB,oBACpB,MACA,WACA,WACA,QAIQ;CACR,MAAM,SAAS,EACb,iBAAiB,MACnB;CAIA,MAAM,SAAS,OAAM,MAFC,2BAA2B,MAAM,WAAW,QAAQ,MAAM,EAAA,CAEnD,MAAM;EACjC,KAAK;EACL,QAAQ;EACR,gBAAgB;EAGhB,gBAAgB;CAClB,CAAC;CAED,IAAI,OAAO,iBAAiB;EAC1B,MAAM,aAAa,GAAG,UAAU,GAAG,KAAK;EAExC,OAAO;GACL,cAAc;GACd,iBAAiB,QAAA,GAAOF,IAAAA,cAAAA,CAAc,UAAU,CAAC,CAAC,KAAK,CAAC,MAAK,MAAK,EAAE,KAAwB;EAC9F;CACF;CAEA,OAAO;AACT;;AC1IA,eAAsB,kBACpB,WACA,WACA,QAC2C;CAC3C,MAAM,SAAS,MAAM,oBAAoB,WAAW,WAAW,WAAW,MAAM;CAEhF,IAAI,CAAC,QACH,OAAO;CAGT,OAAO,OAAO,UAAU;AAC1B"}
|
|
1
|
+
{"version":3,"file":"bundlerOptions-C_YYCV7O.cjs","names":["t","transformAsync","t","transformAsync","sep","pkg","dirname","realpathSync","isAbsolute","nodeResolve","getNodeResolveOptions","isBareModuleSpecifier","pathToFileURL","tsConfigPaths","esbuild","optimizeLodashImports","commonjs","json"],"sources":["../src/build/babel/remove-all-options-except.ts","../src/build/plugins/remove-all-except.ts","../src/build/babel/remove-non-referenced-nodes.ts","../src/build/plugins/remove-unused-references.ts","../src/build/shared/extract-mastra-option.ts","../src/build/bundlerOptions.ts"],"sourcesContent":["import { types as t } from '@babel/core';\nimport type { NodePath, PluginObject, types } from '@babel/core';\nimport type { IMastraLogger } from '@internal/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\n\nexport function removeAllOptionsFromMastraExcept(\n result: { hasCustomConfig: boolean },\n option: keyof MastraConfig,\n logger?: IMastraLogger,\n): PluginObject {\n return {\n name: 'remove-all-except-' + option + '-config',\n visitor: {\n ExportNamedDeclaration: {\n // remove all exports, but keep the underlying declarations — the\n // extracted option may reference them (e.g. `export const deployer = ...`\n // used as `new Mastra({ deployer })`). Unreferenced declarations are\n // dropped by the cleanup pass afterwards.\n exit(path) {\n if (path.node.declaration) {\n const [declaration] = path.replaceWith(path.node.declaration);\n // Already traversed — don't requeue, or the NewExpression visitor\n // would append the extracted export a second time.\n declaration.skip();\n } else {\n path.remove();\n }\n },\n },\n\n NewExpression(path, state) {\n // is a variable declaration\n const varDeclaratorPath = path.findParent(path => t.isVariableDeclarator(path.node));\n if (!varDeclaratorPath) {\n return;\n }\n\n const parentNode = path.parentPath.node;\n // check if it's a const of mastra\n if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== 'mastra') {\n return;\n }\n\n let mastraArgs = t.objectExpression([]);\n if (t.isObjectExpression(path.node.arguments[0])) {\n mastraArgs = path.node.arguments[0];\n }\n\n // Find the config property, skipping SpreadElement nodes\n let configProperty = mastraArgs.properties.find(\n prop => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === option,\n );\n let configValue: types.Expression = t.objectExpression([]);\n\n const programPath = path.scope.getProgramParent().path as NodePath<types.Program> | undefined;\n if (!programPath) {\n return;\n }\n\n if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {\n result.hasCustomConfig = true;\n configValue = configProperty.value;\n\n if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {\n const configBinding = state.file.scope.getBinding(option)!;\n\n if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {\n const id = path.scope.generateUidIdentifier(option);\n\n configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init!));\n configValue = id;\n }\n }\n }\n\n // add the deployer export\n const exportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), configValue)]),\n [],\n );\n\n programPath.node.body.push(exportDeclaration);\n },\n\n Program: {\n exit(path) {\n // Add a fallback export if no mastra configuration was found\n const hasExport = path.node.body.some(\n node => node.type === 'ExportNamedDeclaration' || node.type === 'ExportDefaultDeclaration',\n );\n\n if (!hasExport) {\n if (logger) {\n logger.warn('Mastra config could not be extracted', {\n option,\n details:\n 'Please make sure your entry file looks like this:\\nexport const mastra = new Mastra({\\n <option>: <value>\\n})',\n });\n }\n\n const fallbackExportDeclaration = t.exportNamedDeclaration(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),\n [],\n );\n path.node.body.push(fallbackExportDeclaration);\n }\n },\n },\n },\n } satisfies PluginObject;\n}\n","import { transformAsync } from '@babel/core';\nimport type { IMastraLogger } from '@internal/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport type { Plugin, SourceMapInput } from 'rollup';\nimport { removeAllOptionsFromMastraExcept } from '../babel/remove-all-options-except';\n\nexport function removeAllOptionsFromMastraExceptPlugin(\n mastraEntry: string,\n name: keyof MastraConfig,\n result: { hasCustomConfig: boolean },\n options?: { sourcemap?: boolean; logger?: IMastraLogger },\n): Plugin {\n return {\n name: `remove-${name}`,\n transform(code, id) {\n if (id !== mastraEntry) {\n return;\n }\n\n return transformAsync(code, {\n babelrc: false,\n configFile: false,\n filename: id,\n plugins: [() => removeAllOptionsFromMastraExcept(result, name, options?.logger)],\n sourceMaps: options?.sourcemap,\n }).then(result => ({\n code: result!.code!,\n map: result!.map! as SourceMapInput,\n }));\n },\n } satisfies Plugin;\n}\n","import { types as t } from '@babel/core';\nimport type { PluginObject } from '@babel/core';\n\nexport function removeNonReferencedNodes() {\n return {\n name: 'remove-non-referenced-nodes',\n visitor: {\n Program(path) {\n // Get the scope information\n const scope = path.scope;\n\n // Filter body to keep only referenced nodes\n const currentBody = path.get('body');\n const filteredBody = currentBody.filter(childPath => {\n if (childPath.isExportDeclaration()) {\n return true;\n }\n\n // For variable declarations, check if any declared variables are referenced\n if (childPath.isVariableDeclaration()) {\n return childPath.node.declarations.some(decl => {\n if (!t.isIdentifier(decl.id)) {\n return false;\n }\n\n const name = decl.id.name;\n const binding = scope.getBinding(name);\n // Keep if it has references or is exported\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // For function/class declarations, check if they're referenced\n if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {\n if (!t.isIdentifier(childPath.node.id)) {\n return false;\n }\n\n const name = childPath.node.id.name;\n const binding = scope.getBinding(name);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n }\n\n // For imports, check if any imported items are referenced\n if (childPath.isImportDeclaration()) {\n return childPath.node.specifiers.some(specifier => {\n const importedName = specifier.local.name;\n const binding = scope.getBinding(importedName);\n return binding && (binding.referenced || binding.referencePaths.length > 0);\n });\n }\n\n // Default to keeping other node types\n return false;\n });\n\n // Replace the program body with filtered nodes\n path.set(\n 'body',\n filteredBody.map(p => p.node),\n );\n },\n },\n } as PluginObject;\n}\n","import { transformAsync } from '@babel/core';\nimport { removeNonReferencedNodes } from '../babel/remove-non-referenced-nodes';\n\nexport async function recursiveRemoveNonReferencedNodes(code: string): Promise<{ code: string; map: any }> {\n const result = await transformAsync(code, {\n babelrc: false,\n configFile: false,\n plugins: [removeNonReferencedNodes],\n });\n\n // keep looping until the code is not changed\n if (result && result.code! !== code) {\n return recursiveRemoveNonReferencedNodes(result!.code!);\n }\n\n return {\n code: result!.code!,\n map: result!.map!,\n };\n}\n","import { realpathSync } from 'node:fs';\nimport { dirname, isAbsolute, sep } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { IMastraLogger } from '@internal/core/logger';\nimport type { Config as MastraConfig } from '@mastra/core/mastra';\nimport { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport * as pkg from 'empathic/package';\nimport { rollup } from 'rollup';\nimport type { Plugin, RollupOutput } from 'rollup';\nimport { esbuild } from '../plugins/esbuild';\nimport { removeAllOptionsFromMastraExceptPlugin } from '../plugins/remove-all-except';\nimport { recursiveRemoveNonReferencedNodes } from '../plugins/remove-unused-references';\nimport { tsConfigPaths } from '../plugins/tsconfig-paths';\nimport { getNodeResolveOptions, isBareModuleSpecifier } from '../utils';\n\nconst TS_SOURCE = /\\.tsx?$/;\nconst NODE_MODULES = `${sep}node_modules${sep}`;\n\n/**\n * Packages outside node_modules, such as workspace packages, may ship raw TypeScript (e.g. `exports` pointing to\n * `src/index.ts`), which Node cannot load from the extracted config. Inline those so esbuild transpiles them. Bare\n * imports made from inlined sources stay external but are pinned to the file they resolve to from that source: the\n * extracted config lives in `.mastra/output` and can't see the package's own `node_modules` (e.g. pnpm isolated\n * installs). The app's own imports keep resolving by name.\n */\nfunction typescriptSourcesResolver(entryFile: string): Plugin {\n const appPackageJson = pkg.up({ cwd: dirname(entryFile) });\n const appDir = appPackageJson ? dirname(appPackageJson) : dirname(entryFile);\n // App files keep the entry's path, files resolved by node-resolve are real paths\n const appRoots = [appDir + sep, realpathSync(appDir) + sep];\n const isInlinedSource = (file: string) =>\n isAbsolute(file) && !file.includes(NODE_MODULES) && !appRoots.some(root => file.startsWith(root));\n\n const resolver = nodeResolve({\n ...getNodeResolveOptions('node'),\n extensions: ['.mjs', '.js', '.json', '.node', '.ts', '.tsx'],\n });\n const resolveHook = resolver.resolveId!;\n const resolve = typeof resolveHook === 'function' ? resolveHook : resolveHook.handler;\n\n return {\n ...resolver,\n name: 'typescript-sources-resolver',\n async resolveId(id, importer, options) {\n if (!importer || !isBareModuleSpecifier(id)) {\n return null;\n }\n\n // node-resolve passes each result back through `this.resolve`, and the commonjs plugin's resolveId loads every\n // `.js` result to check whether it is CommonJS. With the live context that loads and transforms every installed\n // package reachable from a surviving import, recursively, though all of them end up external.\n const context = Object.create(this, { resolve: { value: async () => null } });\n const resolved = await resolve.call(context, id, importer, options);\n if (!resolved || typeof resolved !== 'object' || resolved.external) {\n return null;\n }\n\n if (TS_SOURCE.test(resolved.id) && !resolved.id.includes(NODE_MODULES)) {\n return resolved.id;\n }\n\n return isInlinedSource(importer) ? { id: pathToFileURL(resolved.id).href, external: true } : null;\n },\n };\n}\n\nexport function extractMastraOptionBundler(\n name: keyof MastraConfig,\n entryFile: string,\n result: {\n hasCustomConfig: boolean;\n },\n logger?: IMastraLogger,\n) {\n return rollup({\n logLevel: 'silent',\n input: {\n [`${name}-config`]: entryFile,\n },\n treeshake: 'smallest',\n plugins: [\n tsConfigPaths(),\n typescriptSourcesResolver(entryFile),\n // transpile typescript to something we understand\n esbuild(),\n optimizeLodashImports({\n include: '**/*.{js,ts,mjs,cjs}',\n }),\n commonjs({\n extensions: ['.js', '.ts'],\n strictRequires: 'strict',\n transformMixedEsModules: true,\n ignoreTryCatch: false,\n }),\n json(),\n removeAllOptionsFromMastraExceptPlugin(entryFile, name, result, { logger }),\n // let esbuild remove all unused imports\n esbuild(),\n {\n name: 'cleanup',\n transform(code, id) {\n if (id !== entryFile) {\n return;\n }\n\n return recursiveRemoveNonReferencedNodes(code);\n },\n },\n // let esbuild remove it once more\n esbuild(),\n ],\n });\n}\n\nexport async function extractMastraOption<T extends keyof MastraConfig>(\n name: T,\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<{\n bundleOutput: RollupOutput;\n getConfig: () => Promise<MastraConfig[T]>;\n} | null> {\n const result = {\n hasCustomConfig: false,\n };\n\n const bundler = await extractMastraOptionBundler(name, entryFile, result, logger);\n\n const output = await bundler.write({\n dir: outputDir,\n format: 'es',\n entryFileNames: '[name].mjs',\n // Chunks are written outside any package with \"type\": \"module\", so a `.js` chunk would be loaded as CommonJS\n // (#28491). The hash keeps them distinct from the main bundle's chunks in `.mastra/output`.\n chunkFileNames: '[name]-[hash].mjs',\n });\n\n if (result.hasCustomConfig) {\n const configPath = `${outputDir}/${name}-config.mjs`;\n\n return {\n bundleOutput: output,\n getConfig: () => import(pathToFileURL(configPath).href).then(m => m[name] as MastraConfig[T]),\n };\n }\n\n return null;\n}\n","import type { IMastraLogger } from '@internal/core/logger';\nimport type { BundlerConfig } from '@internal/deployer';\nimport { extractMastraOption, extractMastraOptionBundler } from './shared/extract-mastra-option';\n\nexport function getBundlerOptionsBundler(\n entryFile: string,\n result: {\n hasCustomConfig: false;\n },\n) {\n return extractMastraOptionBundler('bundler', entryFile, result);\n}\n\nexport async function getBundlerOptions(\n entryFile: string,\n outputDir: string,\n logger?: IMastraLogger,\n): Promise<BundlerConfig | undefined | null> {\n const result = await extractMastraOption('bundler', entryFile, outputDir, logger);\n\n if (!result) {\n return null;\n }\n\n return result.getConfig();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAKA,SAAgB,iCACd,QACA,QACA,QACc;CACd,OAAO;EACL,MAAM,uBAAuB,SAAS;EACtC,SAAS;GACP,wBAAwB,EAKtB,KAAK,MAAM;IACT,IAAI,KAAK,KAAK,aAAa;KACzB,MAAM,CAAC,eAAe,KAAK,YAAY,KAAK,KAAK,WAAW;KAG5D,YAAY,KAAK;IACnB,OACE,KAAK,OAAO;GAEhB,EACF;GAEA,cAAc,MAAM,OAAO;IAGzB,IAAI,CADsB,KAAK,YAAW,SAAQA,YAAAA,MAAE,qBAAqB,KAAK,IAAI,CAC7D,GACnB;IAGF,MAAM,aAAa,KAAK,WAAW;IAEnC,IAAI,CAACA,YAAAA,MAAE,qBAAqB,UAAU,KAAK,CAACA,YAAAA,MAAE,aAAa,WAAW,EAAE,KAAK,WAAW,GAAG,SAAS,UAClG;IAGF,IAAI,aAAaA,YAAAA,MAAE,iBAAiB,CAAC,CAAC;IACtC,IAAIA,YAAAA,MAAE,mBAAmB,KAAK,KAAK,UAAU,EAAE,GAC7C,aAAa,KAAK,KAAK,UAAU;IAInC,IAAI,iBAAiB,WAAW,WAAW,MACzC,SAAQA,YAAAA,MAAE,iBAAiB,IAAI,KAAKA,YAA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,kCAAkC,IAAI;IAC/C;GACF;GAEAA,gBAAAA,QAAQ;EACV;CACF,CAAC;AACH;AAEA,eAAsB,oBACpB,MACA,WACA,WACA,QAIQ;CACR,MAAM,SAAS,EACb,iBAAiB,MACnB;CAIA,MAAM,SAAS,OAAM,MAFC,2BAA2B,MAAM,WAAW,QAAQ,MAAM,EAAA,CAEnD,MAAM;EACjC,KAAK;EACL,QAAQ;EACR,gBAAgB;EAGhB,gBAAgB;CAClB,CAAC;CAED,IAAI,OAAO,iBAAiB;EAC1B,MAAM,aAAa,GAAG,UAAU,GAAG,KAAK;EAExC,OAAO;GACL,cAAc;GACd,iBAAiB,QAAA,GAAOF,IAAAA,cAAAA,CAAc,UAAU,CAAC,CAAC,KAAK,CAAC,MAAK,MAAK,EAAE,KAAwB;EAC9F;CACF;CAEA,OAAO;AACT;;AC1IA,eAAsB,kBACpB,WACA,WACA,QAC2C;CAC3C,MAAM,SAAS,MAAM,oBAAoB,WAAW,WAAW,WAAW,MAAM;CAEhF,IAAI,CAAC,QACH,OAAO;CAGT,OAAO,OAAO,UAAU;AAC1B"}
|
package/dist/deploy/base.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IDeployer } from '../_types/@internal_deployer@0.0.
|
|
1
|
+
import type { IDeployer } from '../_types/@internal_deployer@0.0.2/dist/index.js';
|
|
2
2
|
import { Bundler } from '../bundler/index.js';
|
|
3
3
|
import { DepsService } from '../services/deps.js';
|
|
4
4
|
export declare abstract class Deployer extends Bundler implements IDeployer {
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_bundler = require("./bundler-
|
|
2
|
+
const require_bundler = require("./bundler-BpXhdDyV.cjs");
|
|
3
3
|
const require_services = require("./services-B8neClCI.cjs");
|
|
4
|
-
require("./build-
|
|
5
|
-
const require_bundlerOptions = require("./bundlerOptions-
|
|
4
|
+
require("./build-BNbmUARF.cjs");
|
|
5
|
+
const require_bundlerOptions = require("./bundlerOptions-C_YYCV7O.cjs");
|
|
6
6
|
// src/deploy/base.ts
|
|
7
7
|
var Deployer = class extends require_bundler.Bundler {
|
|
8
8
|
deps = new require_services.DepsService();
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as Bundler } from "./bundler-
|
|
1
|
+
import { t as Bundler } from "./bundler-CtCtxgyj.js";
|
|
2
2
|
import { c as createPinoStream, i as DepsService, r as Deps, s as createChildProcessLogger, t as FileService } from "./services-BKh9M2E5.js";
|
|
3
|
-
import "./build-
|
|
4
|
-
import { n as extractMastraOption } from "./bundlerOptions-
|
|
3
|
+
import "./build-BmIjWY26.js";
|
|
4
|
+
import { n as extractMastraOption } from "./bundlerOptions-B8nx-_mx.js";
|
|
5
5
|
// src/deploy/base.ts
|
|
6
6
|
var Deployer = class extends Bundler {
|
|
7
7
|
deps = new DepsService();
|
package/dist/server/index.cjs
CHANGED
|
@@ -3574,13 +3574,6 @@ async function setupBrowserStream(app, config) {
|
|
|
3574
3574
|
registry
|
|
3575
3575
|
};
|
|
3576
3576
|
}
|
|
3577
|
-
let _hasPermissionPromise;
|
|
3578
|
-
function loadHasPermission() {
|
|
3579
|
-
if (!_hasPermissionPromise) _hasPermissionPromise = import("@mastra/core/auth/ee").then((m) => m.hasPermission).catch(() => {
|
|
3580
|
-
console.error("[@mastra/hono] Auth features require @mastra/core >= 1.6.0. Please upgrade: npm install @mastra/core@latest");
|
|
3581
|
-
});
|
|
3582
|
-
return _hasPermissionPromise;
|
|
3583
|
-
}
|
|
3584
3577
|
/**
|
|
3585
3578
|
* Wrap a Hono middleware handler so it becomes a no-op for framework-public
|
|
3586
3579
|
* routes (routes registered with `requiresAuth: false`).
|
|
@@ -3635,6 +3628,19 @@ function cancelUnreadBodyOnAbort(response, signal) {
|
|
|
3635
3628
|
if (signal.aborted) cancel();
|
|
3636
3629
|
else signal.addEventListener("abort", cancel, { once: true });
|
|
3637
3630
|
}
|
|
3631
|
+
const requestClones = /* @__PURE__ */ new WeakMap();
|
|
3632
|
+
/**
|
|
3633
|
+
* Clones a request and keeps the clone alive for as long as the request itself. Node 22 makes a request's body
|
|
3634
|
+
* unreadable once a clone of it is garbage collected, which loses the body for anything that reads the original
|
|
3635
|
+
* later, such as the MCP transport.
|
|
3636
|
+
*/
|
|
3637
|
+
function cloneRequest(request) {
|
|
3638
|
+
const clone = request.clone();
|
|
3639
|
+
const clones = requestClones.get(request);
|
|
3640
|
+
if (clones) clones.push(clone);
|
|
3641
|
+
else requestClones.set(request, [clone]);
|
|
3642
|
+
return clone;
|
|
3643
|
+
}
|
|
3638
3644
|
var MastraServer = class extends _mastra_server_server_adapter.MastraServer {
|
|
3639
3645
|
createContextMiddleware() {
|
|
3640
3646
|
return async (c, next) => {
|
|
@@ -3654,7 +3660,7 @@ var MastraServer = class extends _mastra_server_server_adapter.MastraServer {
|
|
|
3654
3660
|
const contentType = c.req.header("content-type");
|
|
3655
3661
|
const contentLength = c.req.header("content-length");
|
|
3656
3662
|
if (contentType?.includes("application/json") && contentLength !== "0") try {
|
|
3657
|
-
const body = await c.req.raw
|
|
3663
|
+
const body = await cloneRequest(c.req.raw).json();
|
|
3658
3664
|
if (body.requestContext) bodyRequestContext = body.requestContext;
|
|
3659
3665
|
} catch {}
|
|
3660
3666
|
}
|
|
@@ -3764,7 +3770,7 @@ var MastraServer = class extends _mastra_server_server_adapter.MastraServer {
|
|
|
3764
3770
|
bodyParseError = { message: error instanceof Error ? error.message : "Failed to parse multipart form data" };
|
|
3765
3771
|
}
|
|
3766
3772
|
else if (contentType.includes("application/json")) {
|
|
3767
|
-
const bodyText = await request.raw
|
|
3773
|
+
const bodyText = await cloneRequest(request.raw).text();
|
|
3768
3774
|
if (bodyText && bodyText.trim().length > 0) try {
|
|
3769
3775
|
body = JSON.parse(bodyText);
|
|
3770
3776
|
} catch (error) {
|
|
@@ -3802,6 +3808,10 @@ var MastraServer = class extends _mastra_server_server_adapter.MastraServer {
|
|
|
3802
3808
|
}
|
|
3803
3809
|
return result;
|
|
3804
3810
|
}
|
|
3811
|
+
/** Adapter `mcpOptions` win; otherwise use `server.mcpOptions` from the Mastra config. */
|
|
3812
|
+
resolveMcpOptions() {
|
|
3813
|
+
return this.mcpOptions ?? this.mastra.getServer()?.mcpOptions;
|
|
3814
|
+
}
|
|
3805
3815
|
async sendResponse(route, response, result, prefix) {
|
|
3806
3816
|
const resolvedPrefix = prefix ?? this.prefix ?? "";
|
|
3807
3817
|
if (result && typeof result === "object" && "__refreshHeaders" in result) {
|
|
@@ -3819,7 +3829,7 @@ var MastraServer = class extends _mastra_server_server_adapter.MastraServer {
|
|
|
3819
3829
|
const { server, httpPath, mcpOptions: routeMcpOptions } = result;
|
|
3820
3830
|
const { req, res } = toReqRes(response.req.raw);
|
|
3821
3831
|
const { setRequestAuth, ...options } = {
|
|
3822
|
-
...this.
|
|
3832
|
+
...this.resolveMcpOptions(),
|
|
3823
3833
|
...routeMcpOptions
|
|
3824
3834
|
};
|
|
3825
3835
|
await (0, _mastra_server_server_adapter.applyMcpRequestAuth)({
|
|
@@ -3861,7 +3871,7 @@ var MastraServer = class extends _mastra_server_server_adapter.MastraServer {
|
|
|
3861
3871
|
await (0, _mastra_server_server_adapter.applyMcpRequestAuth)({
|
|
3862
3872
|
req,
|
|
3863
3873
|
requestContext: response.get("requestContext"),
|
|
3864
|
-
setRequestAuth: this.
|
|
3874
|
+
setRequestAuth: this.resolveMcpOptions()?.setRequestAuth
|
|
3865
3875
|
});
|
|
3866
3876
|
return await server.startHonoSSE({
|
|
3867
3877
|
url: new URL(response.req.url),
|
|
@@ -3986,27 +3996,15 @@ var MastraServer = class extends _mastra_server_server_adapter.MastraServer {
|
|
|
3986
3996
|
routePrefix: prefix,
|
|
3987
3997
|
request: c.req.raw
|
|
3988
3998
|
};
|
|
3989
|
-
const
|
|
3990
|
-
if (this.mastra.getStudio?.()?.auth || this.mastra.getServer()?.auth) {
|
|
3991
|
-
const hasPermission = await loadHasPermission();
|
|
3992
|
-
if (hasPermission) {
|
|
3993
|
-
const userPermissions = requestContext.get("mastra__userPermissions");
|
|
3994
|
-
const permissionError = this.checkRoutePermission(route, userPermissions, hasPermission, requestContext);
|
|
3995
|
-
if (permissionError) return c.json({
|
|
3996
|
-
error: permissionError.error,
|
|
3997
|
-
message: permissionError.message
|
|
3998
|
-
}, permissionError.status);
|
|
3999
|
-
}
|
|
4000
|
-
}
|
|
4001
|
-
const fgaError = await (0, _mastra_server_server_adapter.checkRouteFGA)(this.mastra, route, c.get("requestContext"), {
|
|
3999
|
+
const authzError = await this.authorizeRoute(route, {
|
|
4002
4000
|
...params.urlParams,
|
|
4003
4001
|
...params.queryParams,
|
|
4004
4002
|
...typeof params.body === "object" ? params.body : {}
|
|
4005
|
-
});
|
|
4006
|
-
if (
|
|
4007
|
-
error:
|
|
4008
|
-
message:
|
|
4009
|
-
},
|
|
4003
|
+
}, c.get("requestContext"));
|
|
4004
|
+
if (authzError) return c.json({
|
|
4005
|
+
error: authzError.error,
|
|
4006
|
+
message: authzError.message
|
|
4007
|
+
}, authzError.status);
|
|
4010
4008
|
try {
|
|
4011
4009
|
const result = await route.handler(handlerParams);
|
|
4012
4010
|
return this.sendResponse(route, c, result, prefix);
|
|
@@ -4050,18 +4048,11 @@ var MastraServer = class extends _mastra_server_server_adapter.MastraServer {
|
|
|
4050
4048
|
if (authError.headers) for (const [key, value] of Object.entries(authError.headers)) c.header(key, value);
|
|
4051
4049
|
if (authError.error) return c.json({ error: authError.error }, authError.status);
|
|
4052
4050
|
}
|
|
4053
|
-
const
|
|
4054
|
-
if (
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
const permissionError = this.checkRoutePermission(serverRoute, userPermissions, hasPermission, requestContext);
|
|
4059
|
-
if (permissionError) return c.json({
|
|
4060
|
-
error: permissionError.error,
|
|
4061
|
-
message: permissionError.message
|
|
4062
|
-
}, permissionError.status);
|
|
4063
|
-
}
|
|
4064
|
-
}
|
|
4051
|
+
const permissionError = this.checkRouteRBAC(serverRoute, c.get("requestContext"));
|
|
4052
|
+
if (permissionError) return c.json({
|
|
4053
|
+
error: permissionError.error,
|
|
4054
|
+
message: permissionError.message
|
|
4055
|
+
}, permissionError.status);
|
|
4065
4056
|
const pristineRequest = c.get(MASTRA_PRISTINE_REQUEST_KEY) ?? c.req.raw;
|
|
4066
4057
|
let bodyParams = {};
|
|
4067
4058
|
if ((0, _mastra_server_server_adapter.getFGAProvider)(this.mastra, c.get("requestContext"))) {
|