@mastra/deployer 0.0.0-error-handler-fix-20251020202607 → 0.0.0-execa-dynamic-import-20260304221256
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 +1850 -5
- package/LICENSE.md +15 -0
- package/dist/arktype-aI7TBD0R-MD6ESOAI.js +8 -0
- package/dist/arktype-aI7TBD0R-MD6ESOAI.js.map +1 -0
- package/dist/arktype-aI7TBD0R-MS2OLT4Z.cjs +10 -0
- package/dist/arktype-aI7TBD0R-MS2OLT4Z.cjs.map +1 -0
- package/dist/build/analyze/analyzeEntry.d.ts +8 -4
- package/dist/build/analyze/analyzeEntry.d.ts.map +1 -1
- package/dist/build/analyze/bundleExternals.d.ts +8 -7
- package/dist/build/analyze/bundleExternals.d.ts.map +1 -1
- package/dist/build/analyze/constants.d.ts.map +1 -1
- package/dist/build/analyze.cjs +2 -2
- package/dist/build/analyze.d.ts +7 -7
- package/dist/build/analyze.d.ts.map +1 -1
- package/dist/build/analyze.js +1 -1
- package/dist/build/babel/remove-all-options-except.d.ts +1 -1
- package/dist/build/babel/remove-all-options-except.d.ts.map +1 -1
- package/dist/build/babel/remove-deployer.d.ts.map +1 -1
- package/dist/build/bundler.cjs +3 -3
- package/dist/build/bundler.d.ts +5 -3
- package/dist/build/bundler.d.ts.map +1 -1
- package/dist/build/bundler.js +1 -1
- package/dist/build/bundlerOptions.d.ts +1 -1
- package/dist/build/bundlerOptions.d.ts.map +1 -1
- package/dist/build/deployer.d.ts +1 -1
- package/dist/build/deployer.d.ts.map +1 -1
- package/dist/build/index.cjs +31 -22
- package/dist/build/index.d.ts +2 -1
- package/dist/build/index.d.ts.map +1 -1
- package/dist/build/index.js +6 -5
- package/dist/build/package-info.d.ts +9 -0
- package/dist/build/package-info.d.ts.map +1 -0
- package/dist/build/plugins/esm-shim.d.ts +14 -0
- package/dist/build/plugins/esm-shim.d.ts.map +1 -0
- package/dist/build/plugins/module-resolve-map.d.ts +3 -0
- package/dist/build/plugins/module-resolve-map.d.ts.map +1 -0
- package/dist/build/plugins/node-gyp-detector.d.ts +3 -0
- package/dist/build/plugins/node-gyp-detector.d.ts.map +1 -0
- package/dist/build/plugins/node-modules-extension-resolver.d.ts +7 -0
- package/dist/build/plugins/node-modules-extension-resolver.d.ts.map +1 -1
- package/dist/build/plugins/pino.d.ts.map +1 -1
- package/dist/build/plugins/remove-all-except.d.ts +10 -0
- package/dist/build/plugins/remove-all-except.d.ts.map +1 -0
- package/dist/build/plugins/subpath-externals-resolver.d.ts +3 -0
- package/dist/build/plugins/subpath-externals-resolver.d.ts.map +1 -0
- package/dist/build/plugins/tsconfig-paths.d.ts +8 -0
- package/dist/build/plugins/tsconfig-paths.d.ts.map +1 -1
- package/dist/build/serverOptions.d.ts +1 -1
- package/dist/build/serverOptions.d.ts.map +1 -1
- package/dist/build/shared/extract-mastra-option.d.ts +5 -9
- package/dist/build/shared/extract-mastra-option.d.ts.map +1 -1
- package/dist/build/types.d.ts +18 -0
- package/dist/build/types.d.ts.map +1 -1
- package/dist/build/utils.d.ts +79 -4
- package/dist/build/utils.d.ts.map +1 -1
- package/dist/build/watcher.d.ts +4 -1
- package/dist/build/watcher.d.ts.map +1 -1
- package/dist/bundler/index.cjs +6 -2
- package/dist/bundler/index.d.ts +13 -10
- package/dist/bundler/index.d.ts.map +1 -1
- package/dist/bundler/index.js +1 -1
- package/dist/chunk-32UHMKRP.cjs +95 -0
- package/dist/chunk-32UHMKRP.cjs.map +1 -0
- package/dist/chunk-6UIXBIO6.js +1322 -0
- package/dist/chunk-6UIXBIO6.js.map +1 -0
- package/dist/chunk-73SEUI3W.cjs +1353 -0
- package/dist/chunk-73SEUI3W.cjs.map +1 -0
- package/dist/chunk-ANF3UFZ3.js +318 -0
- package/dist/chunk-ANF3UFZ3.js.map +1 -0
- package/dist/{chunk-5QFG6SCM.js → chunk-DPDWM7HQ.js} +2 -2
- package/dist/chunk-DPDWM7HQ.js.map +1 -0
- package/dist/chunk-EBHDMP6N.cjs +122 -0
- package/dist/chunk-EBHDMP6N.cjs.map +1 -0
- package/dist/{chunk-WAWEQ3DP.js → chunk-EZBW45SX.js} +72 -32
- package/dist/chunk-EZBW45SX.js.map +1 -0
- package/dist/chunk-G7R456H2.cjs +108 -0
- package/dist/chunk-G7R456H2.cjs.map +1 -0
- package/dist/chunk-IMLDKOVJ.js +98 -0
- package/dist/chunk-IMLDKOVJ.js.map +1 -0
- package/dist/chunk-JNSGICDP.js +159 -0
- package/dist/chunk-JNSGICDP.js.map +1 -0
- package/dist/{chunk-3JYRSECU.cjs → chunk-JVBCN3RH.cjs} +4 -4
- package/dist/chunk-JVBCN3RH.cjs.map +1 -0
- package/dist/{chunk-LGC3GUMR.cjs → chunk-MEHKYO3L.cjs} +89 -153
- package/dist/chunk-MEHKYO3L.cjs.map +1 -0
- package/dist/chunk-NQTC7BHX.cjs +4 -0
- package/dist/chunk-NQTC7BHX.cjs.map +1 -0
- package/dist/chunk-O73YCD6A.js +262 -0
- package/dist/chunk-O73YCD6A.js.map +1 -0
- package/dist/chunk-PF6MO6L3.cjs +162 -0
- package/dist/chunk-PF6MO6L3.cjs.map +1 -0
- package/dist/{chunk-HMMDNIEQ.cjs → chunk-R2SYO6PH.cjs} +79 -39
- package/dist/chunk-R2SYO6PH.cjs.map +1 -0
- package/dist/chunk-TFSGAJE4.cjs +16 -0
- package/dist/chunk-TFSGAJE4.cjs.map +1 -0
- package/dist/chunk-UCL7MHBL.js +93 -0
- package/dist/chunk-UCL7MHBL.js.map +1 -0
- package/dist/chunk-UPVHAZ5Q.cjs +288 -0
- package/dist/chunk-UPVHAZ5Q.cjs.map +1 -0
- package/dist/chunk-UQZFTY5Q.cjs +8 -0
- package/dist/chunk-UQZFTY5Q.cjs.map +1 -0
- package/dist/{chunk-465ZVXAK.js → chunk-USX4L64H.js} +83 -146
- package/dist/chunk-USX4L64H.js.map +1 -0
- package/dist/chunk-V3HWDUN7.js +6 -0
- package/dist/chunk-V3HWDUN7.js.map +1 -0
- package/dist/chunk-WGU72NH4.js +14 -0
- package/dist/chunk-WGU72NH4.js.map +1 -0
- package/dist/chunk-XN3FKMO6.js +97 -0
- package/dist/chunk-XN3FKMO6.js.map +1 -0
- package/dist/chunk-YEOQZ6LM.js +3 -0
- package/dist/chunk-YEOQZ6LM.js.map +1 -0
- package/dist/chunk-YIUDHDPS.cjs +351 -0
- package/dist/chunk-YIUDHDPS.cjs.map +1 -0
- package/dist/default-u_dwuiYb-BOJNVDPF.js +3 -0
- package/dist/default-u_dwuiYb-BOJNVDPF.js.map +1 -0
- package/dist/default-u_dwuiYb-HYOFMURU.cjs +9 -0
- package/dist/default-u_dwuiYb-HYOFMURU.cjs.map +1 -0
- package/dist/deploy/log.d.ts +1 -1
- package/dist/deploy/log.d.ts.map +1 -1
- package/dist/docs/SKILL.md +31 -0
- package/dist/docs/assets/SOURCE_MAP.json +27 -0
- package/dist/docs/references/docs-deployment-cloud-providers.md +15 -0
- package/dist/docs/references/docs-deployment-mastra-server.md +122 -0
- package/dist/docs/references/docs-deployment-monorepo.md +142 -0
- package/dist/docs/references/docs-deployment-overview.md +62 -0
- package/dist/docs/references/docs-deployment-web-framework.md +52 -0
- package/dist/docs/references/docs-deployment-workflow-runners.md +9 -0
- package/dist/docs/references/reference-deployer.md +100 -0
- package/dist/effect-QlVUlMFu-FWNF43NY.cjs +17 -0
- package/dist/effect-QlVUlMFu-FWNF43NY.cjs.map +1 -0
- package/dist/effect-QlVUlMFu-UDX7FFQO.js +15 -0
- package/dist/effect-QlVUlMFu-UDX7FFQO.js.map +1 -0
- package/dist/esm-6PM2YB3Y.cjs +1336 -0
- package/dist/esm-6PM2YB3Y.cjs.map +1 -0
- package/dist/esm-CAB7GAHT.js +1289 -0
- package/dist/esm-CAB7GAHT.js.map +1 -0
- package/dist/index.cjs +11 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -16
- package/dist/index.js.map +1 -1
- package/dist/server/handlers/a2a.d.ts +1 -1
- package/dist/server/handlers/health.d.ts +5 -0
- package/dist/server/handlers/health.d.ts.map +1 -0
- package/dist/server/handlers/restart-active-runs.d.ts +3 -0
- package/dist/server/handlers/restart-active-runs.d.ts.map +1 -0
- package/dist/server/handlers/utils/query-parsers.d.ts +15 -0
- package/dist/server/handlers/utils/query-parsers.d.ts.map +1 -1
- package/dist/server/handlers/utils.d.ts +0 -7
- package/dist/server/handlers/utils.d.ts.map +1 -1
- package/dist/server/index.cjs +2983 -10849
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.ts +3 -12
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2983 -10850
- package/dist/server/index.js.map +1 -1
- package/dist/server/types.d.ts +1 -1
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/welcome.d.ts +1 -1
- package/dist/server/welcome.d.ts.map +1 -1
- package/dist/services/index.cjs +4 -4
- package/dist/services/index.js +1 -1
- package/dist/sury-CWZTCd75-2U3FQUNZ.cjs +17 -0
- package/dist/sury-CWZTCd75-2U3FQUNZ.cjs.map +1 -0
- package/dist/sury-CWZTCd75-52HHC6OD.js +15 -0
- package/dist/sury-CWZTCd75-52HHC6OD.js.map +1 -0
- package/dist/typebox-Dei93FPO-EBJ4ULZC.cjs +10 -0
- package/dist/typebox-Dei93FPO-EBJ4ULZC.cjs.map +1 -0
- package/dist/typebox-Dei93FPO-TURR2FV5.js +8 -0
- package/dist/typebox-Dei93FPO-TURR2FV5.js.map +1 -0
- package/dist/valibot--1zFm7rT-KH26NMFX.cjs +17 -0
- package/dist/valibot--1zFm7rT-KH26NMFX.cjs.map +1 -0
- package/dist/valibot--1zFm7rT-O4VBDBTD.js +15 -0
- package/dist/valibot--1zFm7rT-O4VBDBTD.js.map +1 -0
- package/dist/valibot-D_HTw1Gn-EVIH6VOI.js +43 -0
- package/dist/valibot-D_HTw1Gn-EVIH6VOI.js.map +1 -0
- package/dist/valibot-D_HTw1Gn-YHTB53Q2.cjs +45 -0
- package/dist/valibot-D_HTw1Gn-YHTB53Q2.cjs.map +1 -0
- package/dist/validator/custom-resolver.cjs +46 -12
- package/dist/validator/custom-resolver.cjs.map +1 -1
- package/dist/validator/custom-resolver.d.ts +15 -1
- package/dist/validator/custom-resolver.d.ts.map +1 -1
- package/dist/validator/custom-resolver.js +44 -11
- package/dist/validator/custom-resolver.js.map +1 -1
- package/dist/validator/validate.d.ts +16 -1
- package/dist/validator/validate.d.ts.map +1 -1
- package/dist/zod-Bwrt9trS-SFESLKHY.cjs +31 -0
- package/dist/zod-Bwrt9trS-SFESLKHY.cjs.map +1 -0
- package/dist/zod-Bwrt9trS-UDJPKIQS.js +29 -0
- package/dist/zod-Bwrt9trS-UDJPKIQS.js.map +1 -0
- package/dist/zod-DSgpEGAE-3CP5FXLX.cjs +39 -0
- package/dist/zod-DSgpEGAE-3CP5FXLX.cjs.map +1 -0
- package/dist/zod-DSgpEGAE-EQI5QBJK.js +37 -0
- package/dist/zod-DSgpEGAE-EQI5QBJK.js.map +1 -0
- package/package.json +34 -35
- package/dist/build/babel/get-deployer.d.ts +0 -3
- package/dist/build/babel/get-deployer.d.ts.map +0 -1
- package/dist/build/babel/remove-all-options-bundler.d.ts +0 -5
- package/dist/build/babel/remove-all-options-bundler.d.ts.map +0 -1
- package/dist/build/babel/remove-all-options-deployer.d.ts +0 -5
- package/dist/build/babel/remove-all-options-deployer.d.ts.map +0 -1
- package/dist/build/babel/remove-all-options-server.d.ts +0 -5
- package/dist/build/babel/remove-all-options-server.d.ts.map +0 -1
- package/dist/build/babel/remove-all-options-telemetry.d.ts +0 -5
- package/dist/build/babel/remove-all-options-telemetry.d.ts.map +0 -1
- package/dist/build/customInstrumentation.d.ts +0 -10
- package/dist/build/customInstrumentation.d.ts.map +0 -1
- package/dist/build/telemetry.d.ts +0 -8
- package/dist/build/telemetry.d.ts.map +0 -1
- package/dist/chunk-3JYRSECU.cjs.map +0 -1
- package/dist/chunk-465ZVXAK.js.map +0 -1
- package/dist/chunk-5QFG6SCM.js.map +0 -1
- package/dist/chunk-CEXVMFUD.js +0 -1265
- package/dist/chunk-CEXVMFUD.js.map +0 -1
- package/dist/chunk-CKUCDCGI.js +0 -168
- package/dist/chunk-CKUCDCGI.js.map +0 -1
- package/dist/chunk-HMMDNIEQ.cjs.map +0 -1
- package/dist/chunk-LGC3GUMR.cjs.map +0 -1
- package/dist/chunk-MCDDO4WY.cjs +0 -1309
- package/dist/chunk-MCDDO4WY.cjs.map +0 -1
- package/dist/chunk-OYO2MJED.cjs +0 -195
- package/dist/chunk-OYO2MJED.cjs.map +0 -1
- package/dist/chunk-SBTEIZ3B.js +0 -26
- package/dist/chunk-SBTEIZ3B.js.map +0 -1
- package/dist/chunk-WAWEQ3DP.js.map +0 -1
- package/dist/chunk-WIQEFIRX.cjs +0 -28
- package/dist/chunk-WIQEFIRX.cjs.map +0 -1
- package/dist/server/handlers/auth/defaults.d.ts +0 -3
- package/dist/server/handlers/auth/defaults.d.ts.map +0 -1
- package/dist/server/handlers/auth/helpers.d.ts +0 -11
- package/dist/server/handlers/auth/helpers.d.ts.map +0 -1
- package/dist/server/handlers/auth/index.d.ts +0 -11
- package/dist/server/handlers/auth/index.d.ts.map +0 -1
- package/dist/server/handlers/prompt.d.ts +0 -3
- package/dist/server/handlers/prompt.d.ts.map +0 -1
- package/dist/server/handlers/routes/agent-builder/handlers.d.ts +0 -17
- package/dist/server/handlers/routes/agent-builder/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/agent-builder/router.d.ts +0 -4
- package/dist/server/handlers/routes/agent-builder/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/agents/handlers.d.ts +0 -363
- package/dist/server/handlers/routes/agents/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/agents/router.d.ts +0 -5
- package/dist/server/handlers/routes/agents/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/agents/voice.d.ts +0 -18
- package/dist/server/handlers/routes/agents/voice.d.ts.map +0 -1
- package/dist/server/handlers/routes/logs/handlers.d.ts +0 -5
- package/dist/server/handlers/routes/logs/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/logs/router.d.ts +0 -3
- package/dist/server/handlers/routes/logs/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/mcp/handlers.d.ts +0 -139
- package/dist/server/handlers/routes/mcp/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/mcp/router.d.ts +0 -4
- package/dist/server/handlers/routes/mcp/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/memory/handlers.d.ts +0 -17
- package/dist/server/handlers/routes/memory/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/memory/router.d.ts +0 -4
- package/dist/server/handlers/routes/memory/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/observability/handlers.d.ts +0 -6
- package/dist/server/handlers/routes/observability/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/observability/router.d.ts +0 -3
- package/dist/server/handlers/routes/observability/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/scores/handlers.d.ts +0 -300
- package/dist/server/handlers/routes/scores/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/scores/router.d.ts +0 -4
- package/dist/server/handlers/routes/scores/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/telemetry/handlers.d.ts +0 -4
- package/dist/server/handlers/routes/telemetry/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/telemetry/router.d.ts +0 -3
- package/dist/server/handlers/routes/telemetry/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/tools/handlers.d.ts +0 -7
- package/dist/server/handlers/routes/tools/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/tools/router.d.ts +0 -4
- package/dist/server/handlers/routes/tools/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/vector/handlers.d.ts +0 -10
- package/dist/server/handlers/routes/vector/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/vector/router.d.ts +0 -4
- package/dist/server/handlers/routes/vector/router.d.ts.map +0 -1
- package/dist/server/handlers/routes/workflows/handlers.d.ts +0 -20
- package/dist/server/handlers/routes/workflows/handlers.d.ts.map +0 -1
- package/dist/server/handlers/routes/workflows/legacyWorkflows.d.ts +0 -11
- package/dist/server/handlers/routes/workflows/legacyWorkflows.d.ts.map +0 -1
- package/dist/server/handlers/routes/workflows/router.d.ts +0 -4
- package/dist/server/handlers/routes/workflows/router.d.ts.map +0 -1
- package/dist/templates/instrumentation-template.js +0 -172
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkYIUDHDPS_cjs = require('./chunk-YIUDHDPS.cjs');
|
|
4
|
+
var chunkG7R456H2_cjs = require('./chunk-G7R456H2.cjs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var url = require('url');
|
|
7
|
+
var rollupPlugin = require('@optimize-lodash/rollup-plugin');
|
|
4
8
|
var alias = require('@rollup/plugin-alias');
|
|
5
9
|
var commonjs = require('@rollup/plugin-commonjs');
|
|
6
10
|
var json = require('@rollup/plugin-json');
|
|
7
11
|
var nodeResolve = require('@rollup/plugin-node-resolve');
|
|
8
|
-
var esmShim = require('@rollup/plugin-esm-shim');
|
|
9
|
-
var url = require('url');
|
|
10
12
|
var rollup = require('rollup');
|
|
11
|
-
var
|
|
12
|
-
var path = require('path');
|
|
13
|
+
var promises = require('fs/promises');
|
|
13
14
|
|
|
14
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
16
|
|
|
@@ -17,41 +18,79 @@ var alias__default = /*#__PURE__*/_interopDefault(alias);
|
|
|
17
18
|
var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
|
|
18
19
|
var json__default = /*#__PURE__*/_interopDefault(json);
|
|
19
20
|
var nodeResolve__default = /*#__PURE__*/_interopDefault(nodeResolve);
|
|
20
|
-
var esmShim__default = /*#__PURE__*/_interopDefault(esmShim);
|
|
21
21
|
|
|
22
|
+
async function getPackageJSON(pkgName, importer) {
|
|
23
|
+
const pkgRoot = await chunkYIUDHDPS_cjs.getPackageRootPath(pkgName, importer);
|
|
24
|
+
if (!pkgRoot) {
|
|
25
|
+
throw new Error(`Package ${pkgName} not found`);
|
|
26
|
+
}
|
|
27
|
+
const pkgJSON = JSON.parse(await promises.readFile(path.join(pkgRoot, "package.json"), "utf-8"));
|
|
28
|
+
return pkgJSON;
|
|
29
|
+
}
|
|
30
|
+
function nodeModulesExtensionResolver() {
|
|
31
|
+
const nodeResolvePlugin = nodeResolve__default.default();
|
|
32
|
+
return {
|
|
33
|
+
name: "node-modules-extension-resolver",
|
|
34
|
+
async resolveId(id, importer, options) {
|
|
35
|
+
if (!importer || id.startsWith(".") || id.startsWith("/") || chunkG7R456H2_cjs.isBuiltinModule(id) || path.isAbsolute(id)) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const parts = id.split("/");
|
|
39
|
+
const isScoped = id.startsWith("@");
|
|
40
|
+
if (isScoped && parts.length === 2 || !isScoped && parts.length === 1) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const pkgName = chunkG7R456H2_cjs.getPackageName(id);
|
|
44
|
+
if (!pkgName) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const packageJSON = await getPackageJSON(pkgName, importer);
|
|
49
|
+
if (!!packageJSON.exports) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const packageRoot = await chunkYIUDHDPS_cjs.getPackageRootPath(pkgName, importer);
|
|
53
|
+
const nodeResolved = await nodeResolvePlugin.resolveId?.handler?.call(this, id, importer, options);
|
|
54
|
+
if (!nodeResolved?.id) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
let filePath = nodeResolved.id;
|
|
58
|
+
if (nodeResolved.resolvedBy === "commonjs--resolver") {
|
|
59
|
+
filePath = filePath.substring(1).split("?")[0];
|
|
60
|
+
}
|
|
61
|
+
const resolvedImportPath = filePath.replace(packageRoot, pkgName);
|
|
62
|
+
return {
|
|
63
|
+
id: resolvedImportPath,
|
|
64
|
+
external: true
|
|
65
|
+
};
|
|
66
|
+
} catch (err) {
|
|
67
|
+
console.error(err);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/build/bundler.ts
|
|
22
75
|
async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = { "process.env.NODE_ENV": JSON.stringify("production") }, {
|
|
23
76
|
sourcemap = false,
|
|
24
77
|
isDev = false,
|
|
25
78
|
projectRoot,
|
|
26
79
|
workspaceRoot = void 0,
|
|
27
|
-
enableEsmShim = true
|
|
80
|
+
enableEsmShim = true,
|
|
81
|
+
externalsPreset = false
|
|
28
82
|
}) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
preferBuiltins: false,
|
|
34
|
-
browser: true
|
|
35
|
-
});
|
|
36
|
-
const externalsCopy = /* @__PURE__ */ new Set();
|
|
37
|
-
for (const external of analyzedBundleInfo.externalDependencies) {
|
|
38
|
-
if (external.startsWith("@")) {
|
|
39
|
-
const [scope, name] = external.split("/", 3);
|
|
40
|
-
externalsCopy.add(`${scope}/${name}`);
|
|
41
|
-
externalsCopy.add(`${scope}/${name}/*`);
|
|
42
|
-
} else {
|
|
43
|
-
externalsCopy.add(external);
|
|
44
|
-
externalsCopy.add(`${external}/*`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const externals = Array.from(externalsCopy);
|
|
48
|
-
const normalizedEntryFile = chunkMCDDO4WY_cjs.slash(entryFile);
|
|
83
|
+
const nodeResolvePlugin = nodeResolve__default.default(chunkG7R456H2_cjs.getNodeResolveOptions(platform));
|
|
84
|
+
const externalsCopy = new Set(analyzedBundleInfo.externalDependencies.keys());
|
|
85
|
+
const externals = externalsPreset ? [] : Array.from(externalsCopy);
|
|
86
|
+
const normalizedEntryFile = chunkG7R456H2_cjs.slash(entryFile);
|
|
49
87
|
return {
|
|
50
88
|
logLevel: process.env.MASTRA_BUNDLER_DEBUG === "true" ? "debug" : "silent",
|
|
51
89
|
treeshake: "smallest",
|
|
52
90
|
preserveSymlinks: true,
|
|
53
91
|
external: externals,
|
|
54
92
|
plugins: [
|
|
93
|
+
chunkYIUDHDPS_cjs.subpathExternalsResolver(externals),
|
|
55
94
|
{
|
|
56
95
|
name: "alias-optimized-deps",
|
|
57
96
|
resolveId(id) {
|
|
@@ -76,7 +115,7 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
|
|
|
76
115
|
entries: [
|
|
77
116
|
{
|
|
78
117
|
find: /^\#server$/,
|
|
79
|
-
replacement:
|
|
118
|
+
replacement: chunkG7R456H2_cjs.slash(url.fileURLToPath(undefined("@mastra/deployer/server")))
|
|
80
119
|
},
|
|
81
120
|
{
|
|
82
121
|
find: /^\@mastra\/server\/(.*)/,
|
|
@@ -92,7 +131,7 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
|
|
|
92
131
|
{ find: /^\#mastra$/, replacement: normalizedEntryFile }
|
|
93
132
|
]
|
|
94
133
|
}),
|
|
95
|
-
|
|
134
|
+
chunkYIUDHDPS_cjs.tsConfigPaths(),
|
|
96
135
|
{
|
|
97
136
|
name: "tools-rewriter",
|
|
98
137
|
resolveId(id) {
|
|
@@ -104,30 +143,30 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
|
|
|
104
143
|
}
|
|
105
144
|
}
|
|
106
145
|
},
|
|
107
|
-
|
|
146
|
+
chunkYIUDHDPS_cjs.esbuild({
|
|
108
147
|
platform,
|
|
109
148
|
define: env
|
|
110
149
|
}),
|
|
111
150
|
rollupPlugin.optimizeLodashImports({
|
|
112
151
|
include: "**/*.{js,ts,mjs,cjs}"
|
|
113
152
|
}),
|
|
114
|
-
commonjs__default.default({
|
|
153
|
+
externalsPreset ? null : commonjs__default.default({
|
|
115
154
|
extensions: [".js", ".ts"],
|
|
116
155
|
transformMixedEsModules: true,
|
|
117
156
|
esmExternals(id) {
|
|
118
157
|
return externals.includes(id);
|
|
119
158
|
}
|
|
120
159
|
}),
|
|
121
|
-
enableEsmShim ?
|
|
122
|
-
nodeResolvePlugin,
|
|
160
|
+
enableEsmShim ? chunkYIUDHDPS_cjs.esmShim() : void 0,
|
|
161
|
+
externalsPreset ? nodeModulesExtensionResolver() : nodeResolvePlugin,
|
|
123
162
|
// for debugging
|
|
124
163
|
// {
|
|
125
164
|
// name: 'logger',
|
|
126
|
-
// //@ts-
|
|
165
|
+
// //@ts-expect-error
|
|
127
166
|
// resolveId(id, ...args) {
|
|
128
167
|
// console.log({ id, args });
|
|
129
168
|
// },
|
|
130
|
-
// // @ts-
|
|
169
|
+
// // @ts-expect-error
|
|
131
170
|
// transform(code, id) {
|
|
132
171
|
// if (code.includes('class Duplexify ')) {
|
|
133
172
|
// console.log({ duplex: id });
|
|
@@ -135,9 +174,9 @@ async function getInputOptions(entryFile, analyzedBundleInfo, platform, env = {
|
|
|
135
174
|
// },
|
|
136
175
|
// },
|
|
137
176
|
json__default.default(),
|
|
138
|
-
|
|
177
|
+
chunkYIUDHDPS_cjs.removeDeployer(entryFile, { sourcemap }),
|
|
139
178
|
// treeshake unused imports
|
|
140
|
-
|
|
179
|
+
chunkYIUDHDPS_cjs.esbuild({
|
|
141
180
|
include: entryFile,
|
|
142
181
|
platform
|
|
143
182
|
})
|
|
@@ -163,5 +202,6 @@ async function createBundler(inputOptions, outputOptions) {
|
|
|
163
202
|
|
|
164
203
|
exports.createBundler = createBundler;
|
|
165
204
|
exports.getInputOptions = getInputOptions;
|
|
166
|
-
|
|
167
|
-
//# sourceMappingURL=chunk-
|
|
205
|
+
exports.nodeModulesExtensionResolver = nodeModulesExtensionResolver;
|
|
206
|
+
//# sourceMappingURL=chunk-R2SYO6PH.cjs.map
|
|
207
|
+
//# sourceMappingURL=chunk-R2SYO6PH.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/build/plugins/node-modules-extension-resolver.ts","../src/build/bundler.ts"],"names":["getPackageRootPath","readFile","join","nodeResolve","isBuiltinModule","isAbsolute","getPackageName","getNodeResolveOptions","slash","subpathExternalsResolver","pathToFileURL","alias","fileURLToPath","tsConfigPaths","esbuild","optimizeLodashImports","commonjs","esmShim","json","removeDeployer","rollup"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA,eAAe,cAAA,CAAe,SAAiB,QAAA,EAAwC;AACrF,EAAA,MAAM,OAAA,GAAU,MAAMA,oCAAA,CAAmB,OAAA,EAAS,QAAQ,CAAA;AAC1D,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,QAAA,EAAW,OAAO,CAAA,UAAA,CAAY,CAAA;AAAA,EAChD;AAEA,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,KAAA,CAAM,MAAMC,iBAAA,CAASC,UAAK,OAAA,EAAS,cAAc,CAAA,EAAG,OAAO,CAAC,CAAA;AACjF,EAAA,OAAO,OAAA;AACT;AASO,SAAS,4BAAA,GAAuC;AAErD,EAAA,MAAM,oBAAoBC,4BAAA,EAAY;AAEtC,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,iCAAA;AAAA,IACN,MAAM,SAAA,CAAU,EAAA,EAAI,QAAA,EAAU,OAAA,EAAS;AAErC,MAAA,IAAI,CAAC,QAAA,IAAY,EAAA,CAAG,UAAA,CAAW,GAAG,CAAA,IAAK,EAAA,CAAG,UAAA,CAAW,GAAG,KAAKC,iCAAA,CAAgB,EAAE,CAAA,IAAKC,eAAA,CAAW,EAAE,CAAA,EAAG;AAClG,QAAA,OAAO,IAAA;AAAA,MACT;AAGA,MAAA,MAAM,KAAA,GAAQ,EAAA,CAAG,KAAA,CAAM,GAAG,CAAA;AAC1B,MAAA,MAAM,QAAA,GAAW,EAAA,CAAG,UAAA,CAAW,GAAG,CAAA;AAClC,MAAA,IAAK,QAAA,IAAY,MAAM,MAAA,KAAW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AA,GACI,OACAC,yBAAA,CAAS;AAAA,QACP,UAAA,EAAY,CAAC,KAAA,EAAO,KAAK,CAAA;AAAA,QACzB,uBAAA,EAAyB,IAAA;AAAA,QACzB,aAAa,EAAA,EAAI;AACf,UAAA,OAAO,SAAA,CAAU,SAAS,EAAE,CAAA;AAAA,QAC9B;AAAA,OACD,CAAA;AAAA,MACL,aAAA,GAAgBC,2BAAQ,GAAI,MAAA;AAAA,MAC5B,eAAA,GAAkB,8BAA6B,GAAI,iBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAenDC,qBAAA,EAAK;AAAA,MACLC,gCAAA,CAAe,SAAA,EAAW,EAAE,SAAA,EAAW,CAAA;AAAA;AAAA,MAEvCL,yBAAA,CAAQ;AAAA,QACN,OAAA,EAAS,SAAA;AAAA,QACT;AAAA,OACD;AAAA,KACH,CAAE,OAAO,OAAO;AAAA,GAClB;AACF;AAEA,eAAsB,aAAA,CACpB,cACA,aAAA,EACA;AACA,EAAA,MAAM,OAAA,GAAU,MAAMM,aAAA,CAAO,YAAY,CAAA;AAEzC,EAAA,OAAO;AAAA,IACL,OAAO,MAAM;AACX,MAAA,OAAO,QAAQ,KAAA,CAAM;AAAA,QACnB,GAAG,aAAA;AAAA,QACH,MAAA,EAAQ,KAAA;AAAA,QACR,cAAA,EAAgB,YAAA;AAAA,QAChB,cAAA,EAAgB;AAAA,OACjB,CAAA;AAAA,IACH,CAAA;AAAA,IACA,OAAO,MAAM;AACX,MAAA,OAAO,QAAQ,KAAA,EAAM;AAAA,IACvB;AAAA,GACF;AACF","file":"chunk-R2SYO6PH.cjs","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { join, isAbsolute } from 'node:path';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport type { Plugin } from 'rollup';\nimport type { PackageJson } from 'type-fest';\nimport { getPackageRootPath } from '../package-info';\nimport { getPackageName, isBuiltinModule } from '../utils';\n\n/**\n * Check if a package has an exports field in its package.json.\n * Results are cached to avoid repeated filesystem reads.\n */\nasync function getPackageJSON(pkgName: string, importer: string): Promise<PackageJson> {\n const pkgRoot = await getPackageRootPath(pkgName, importer);\n if (!pkgRoot) {\n throw new Error(`Package ${pkgName} not found`);\n }\n\n const pkgJSON = JSON.parse(await readFile(join(pkgRoot, 'package.json'), 'utf-8')) as PackageJson;\n return pkgJSON;\n}\n\n/**\n * Rollup plugin that resolves module extensions for external dependencies.\n *\n * This plugin handles ESM compatibility for external imports when node-resolve is not used:\n * - Packages WITH exports field (e.g., hono, date-fns): Keep imports as-is or strip redundant extensions\n * - Packages WITHOUT exports field (e.g., lodash): Add .js extension for direct file imports\n */\nexport function nodeModulesExtensionResolver(): Plugin {\n // Create a single instance of node-resolve to reuse\n const nodeResolvePlugin = nodeResolve();\n\n return {\n name: 'node-modules-extension-resolver',\n async resolveId(id, importer, options) {\n // Skip relative imports, absolute paths, no importer, or builtin modules\n if (!importer || id.startsWith('.') || id.startsWith('/') || isBuiltinModule(id) || isAbsolute(id)) {\n return null;\n }\n\n // Skip direct package imports (e.g., 'lodash', '@mastra/core')\n const parts = id.split('/');\n const isScoped = id.startsWith('@');\n if ((isScoped && parts.length === 2) || (!isScoped && parts.length === 1)) {\n return null;\n }\n\n const pkgName = getPackageName(id);\n if (!pkgName) {\n return null;\n }\n\n try {\n const packageJSON = await getPackageJSON(pkgName, importer);\n // if it has exports, node should be able to rsolve it, if not the exports map is wrong.\n if (!!packageJSON.exports) {\n return null;\n }\n\n const packageRoot = await getPackageRootPath(pkgName, importer);\n // @ts-expect-error - handle is part of resolveId signature\n const nodeResolved = await nodeResolvePlugin.resolveId?.handler?.call(this, id, importer, options);\n // if we cannot resolve it, it's not a valid import so we let node handle it\n if (!nodeResolved?.id) {\n return null;\n }\n\n let filePath = nodeResolved.id;\n if (nodeResolved.resolvedBy === 'commonjs--resolver') {\n filePath = filePath.substring(1).split('?')[0];\n }\n\n const resolvedImportPath = filePath.replace(packageRoot, pkgName);\n\n return {\n id: resolvedImportPath,\n external: true,\n };\n } catch (err) {\n console.error(err);\n return null;\n }\n },\n };\n}\n","import { join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\nimport { optimizeLodashImports } from '@optimize-lodash/rollup-plugin';\nimport alias from '@rollup/plugin-alias';\nimport commonjs from '@rollup/plugin-commonjs';\nimport json from '@rollup/plugin-json';\nimport nodeResolve from '@rollup/plugin-node-resolve';\nimport { rollup } from 'rollup';\nimport type { InputOptions, OutputOptions, Plugin } from 'rollup';\nimport type { analyzeBundle } from './analyze';\nimport { esbuild } from './plugins/esbuild';\nimport { esmShim } from './plugins/esm-shim';\nimport { nodeModulesExtensionResolver } from './plugins/node-modules-extension-resolver';\nimport { removeDeployer } from './plugins/remove-deployer';\nimport { subpathExternalsResolver } from './plugins/subpath-externals-resolver';\nimport { tsConfigPaths } from './plugins/tsconfig-paths';\nimport { getNodeResolveOptions, slash } from './utils';\nimport type { BundlerPlatform } from './utils';\n\nexport async function getInputOptions(\n entryFile: string,\n analyzedBundleInfo: Awaited<ReturnType<typeof analyzeBundle>>,\n platform: BundlerPlatform,\n env: Record<string, string> = { 'process.env.NODE_ENV': JSON.stringify('production') },\n {\n sourcemap = false,\n isDev = false,\n projectRoot,\n workspaceRoot = undefined,\n enableEsmShim = true,\n externalsPreset = false,\n }: {\n sourcemap?: boolean;\n isDev?: boolean;\n workspaceRoot?: string;\n projectRoot: string;\n enableEsmShim?: boolean;\n externalsPreset?: boolean;\n },\n): Promise<InputOptions> {\n const nodeResolvePlugin = nodeResolve(getNodeResolveOptions(platform));\n\n const externalsCopy = new Set<string>(analyzedBundleInfo.externalDependencies.keys());\n const externals = externalsPreset ? [] : Array.from(externalsCopy);\n\n const normalizedEntryFile = slash(entryFile);\n return {\n logLevel: process.env.MASTRA_BUNDLER_DEBUG === 'true' ? 'debug' : 'silent',\n treeshake: 'smallest',\n preserveSymlinks: true,\n external: externals,\n plugins: [\n subpathExternalsResolver(externals),\n {\n name: 'alias-optimized-deps',\n resolveId(id: string) {\n if (!analyzedBundleInfo.dependencies.has(id)) {\n return null;\n }\n\n const filename = analyzedBundleInfo.dependencies.get(id)!;\n const absolutePath = join(workspaceRoot || projectRoot, filename);\n\n // During `mastra dev` we want to keep deps as external\n if (isDev) {\n return {\n id: process.platform === 'win32' ? pathToFileURL(absolutePath).href : absolutePath,\n external: true,\n };\n }\n\n // For production builds return the absolute path as-is so Rollup can handle itself\n return {\n id: absolutePath,\n external: false,\n };\n },\n } satisfies Plugin,\n alias({\n entries: [\n {\n find: /^\\#server$/,\n replacement: slash(fileURLToPath(import.meta.resolve('@mastra/deployer/server'))),\n },\n {\n find: /^\\@mastra\\/server\\/(.*)/,\n replacement: `@mastra/server/$1`,\n customResolver: id => {\n if (id.startsWith('@mastra/server')) {\n return {\n id: fileURLToPath(import.meta.resolve(id)),\n };\n }\n },\n },\n { find: /^\\#mastra$/, replacement: normalizedEntryFile },\n ],\n }),\n tsConfigPaths(),\n {\n name: 'tools-rewriter',\n resolveId(id: string) {\n if (id === '#tools') {\n return {\n id: './tools.mjs',\n external: true,\n };\n }\n },\n } satisfies Plugin,\n esbuild({\n platform,\n define: env,\n }),\n optimizeLodashImports({\n include: '**/*.{js,ts,mjs,cjs}',\n }),\n externalsPreset\n ? null\n : commonjs({\n extensions: ['.js', '.ts'],\n transformMixedEsModules: true,\n esmExternals(id) {\n return externals.includes(id);\n },\n }),\n enableEsmShim ? esmShim() : undefined,\n externalsPreset ? nodeModulesExtensionResolver() : nodeResolvePlugin,\n // for debugging\n // {\n // name: 'logger',\n // //@ts-expect-error\n // resolveId(id, ...args) {\n // console.log({ id, args });\n // },\n // // @ts-expect-error\n // transform(code, id) {\n // if (code.includes('class Duplexify ')) {\n // console.log({ duplex: id });\n // }\n // },\n // },\n json(),\n removeDeployer(entryFile, { sourcemap }),\n // treeshake unused imports\n esbuild({\n include: entryFile,\n platform,\n }),\n ].filter(Boolean),\n } satisfies InputOptions;\n}\n\nexport async function createBundler(\n inputOptions: InputOptions,\n outputOptions: Partial<OutputOptions> & { dir: string },\n) {\n const bundler = await rollup(inputOptions);\n\n return {\n write: () => {\n return bundler.write({\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].mjs',\n chunkFileNames: '[name].mjs',\n });\n },\n close: () => {\n return bundler.close();\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk32UHMKRP_cjs = require('./chunk-32UHMKRP.cjs');
|
|
4
|
+
var chunkPF6MO6L3_cjs = require('./chunk-PF6MO6L3.cjs');
|
|
5
|
+
|
|
6
|
+
// ../../node_modules/.pnpm/@standard-community+standard-openapi@0.2.9_@standard-community+standard-json@0.3.5_@sta_d040a6944a3a4ac0b81f62afd97a798c/node_modules/@standard-community/standard-openapi/dist/default-u_dwuiYb.js
|
|
7
|
+
function getToOpenAPISchemaFn() {
|
|
8
|
+
return async (schema, context) => chunk32UHMKRP_cjs.convertToOpenAPISchema(
|
|
9
|
+
await chunkPF6MO6L3_cjs.toJsonSchema(schema, context.options),
|
|
10
|
+
context
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.getToOpenAPISchemaFn = getToOpenAPISchemaFn;
|
|
15
|
+
//# sourceMappingURL=chunk-TFSGAJE4.cjs.map
|
|
16
|
+
//# sourceMappingURL=chunk-TFSGAJE4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/@standard-community+standard-openapi@0.2.9_@standard-community+standard-json@0.3.5_@sta_d040a6944a3a4ac0b81f62afd97a798c/node_modules/@standard-community/standard-openapi/dist/default-u_dwuiYb.js"],"names":["convertToOpenAPISchema","toJsonSchema"],"mappings":";;;;;;AAGA,SAAS,oBAAA,GAAuB;AAC9B,EAAA,OAAO,OAAO,QAAQ,OAAA,KAAYA,wCAAA;AAAA,IAChC,MAAMC,8BAAA,CAAa,MAAA,EAAQ,OAAA,CAAQ,OAAO,CAAA;AAAA,IAC1C;AAAA,GACF;AACF","file":"chunk-TFSGAJE4.cjs","sourcesContent":["import { toJsonSchema } from '@standard-community/standard-json';\nimport { convertToOpenAPISchema } from './vendors/convert.js';\n\nfunction getToOpenAPISchemaFn() {\n return async (schema, context) => convertToOpenAPISchema(\n await toJsonSchema(schema, context.options),\n context\n );\n}\n\nexport { getToOpenAPISchemaFn as default };\n"]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// ../../node_modules/.pnpm/@standard-community+standard-openapi@0.2.9_@standard-community+standard-json@0.3.5_@sta_d040a6944a3a4ac0b81f62afd97a798c/node_modules/@standard-community/standard-openapi/dist/vendors/convert.js
|
|
2
|
+
function convertToOpenAPISchema(jsonSchema, context) {
|
|
3
|
+
const _jsonSchema = JSON.parse(JSON.stringify(jsonSchema));
|
|
4
|
+
if ("nullable" in _jsonSchema && _jsonSchema.nullable === true) {
|
|
5
|
+
if (_jsonSchema.type) {
|
|
6
|
+
if (Array.isArray(_jsonSchema.type)) {
|
|
7
|
+
if (!_jsonSchema.type.includes("null")) {
|
|
8
|
+
_jsonSchema.type.push("null");
|
|
9
|
+
}
|
|
10
|
+
} else {
|
|
11
|
+
_jsonSchema.type = [_jsonSchema.type, "null"];
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
_jsonSchema.type = ["null"];
|
|
15
|
+
}
|
|
16
|
+
delete _jsonSchema.nullable;
|
|
17
|
+
}
|
|
18
|
+
if (_jsonSchema.$schema) {
|
|
19
|
+
delete _jsonSchema.$schema;
|
|
20
|
+
}
|
|
21
|
+
const nestedSchemaKeys = [
|
|
22
|
+
"properties",
|
|
23
|
+
"additionalProperties",
|
|
24
|
+
"items",
|
|
25
|
+
"additionalItems",
|
|
26
|
+
"allOf",
|
|
27
|
+
"anyOf",
|
|
28
|
+
"oneOf",
|
|
29
|
+
"not",
|
|
30
|
+
"if",
|
|
31
|
+
"then",
|
|
32
|
+
"else",
|
|
33
|
+
"definitions",
|
|
34
|
+
"$defs",
|
|
35
|
+
"patternProperties",
|
|
36
|
+
"propertyNames",
|
|
37
|
+
"contains"
|
|
38
|
+
// "unevaluatedProperties",
|
|
39
|
+
// "unevaluatedItems",
|
|
40
|
+
];
|
|
41
|
+
nestedSchemaKeys.forEach((key) => {
|
|
42
|
+
if (_jsonSchema[key] && (typeof _jsonSchema[key] === "object" || Array.isArray(_jsonSchema[key]))) {
|
|
43
|
+
if (key === "properties" || key === "definitions" || key === "$defs" || key === "patternProperties") {
|
|
44
|
+
for (const subKey in _jsonSchema[key]) {
|
|
45
|
+
_jsonSchema[key][subKey] = convertToOpenAPISchema(
|
|
46
|
+
_jsonSchema[key][subKey],
|
|
47
|
+
context
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
} else if (key === "allOf" || key === "anyOf" || key === "oneOf") {
|
|
51
|
+
_jsonSchema[key] = _jsonSchema[key].map(
|
|
52
|
+
(item) => convertToOpenAPISchema(item, context)
|
|
53
|
+
);
|
|
54
|
+
} else if (key === "items") {
|
|
55
|
+
if (Array.isArray(_jsonSchema[key])) {
|
|
56
|
+
_jsonSchema[key] = _jsonSchema[key].map(
|
|
57
|
+
(item) => convertToOpenAPISchema(item, context)
|
|
58
|
+
);
|
|
59
|
+
} else {
|
|
60
|
+
_jsonSchema[key] = convertToOpenAPISchema(_jsonSchema[key], context);
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
_jsonSchema[key] = convertToOpenAPISchema(_jsonSchema[key], context);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if (_jsonSchema.ref || _jsonSchema.$id) {
|
|
68
|
+
const { ref, $id, ...component } = _jsonSchema;
|
|
69
|
+
const id = ref || $id;
|
|
70
|
+
context.components.schemas = {
|
|
71
|
+
...context.components.schemas,
|
|
72
|
+
[id]: component
|
|
73
|
+
};
|
|
74
|
+
return {
|
|
75
|
+
$ref: `#/components/schemas/${id}`
|
|
76
|
+
};
|
|
77
|
+
} else if (_jsonSchema.$ref) {
|
|
78
|
+
const { $ref, $defs } = _jsonSchema;
|
|
79
|
+
const ref = $ref.split("/").pop();
|
|
80
|
+
context.components.schemas = {
|
|
81
|
+
...context.components.schemas,
|
|
82
|
+
...$defs
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
$ref: `#/components/schemas/${ref}`
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return _jsonSchema;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export { convertToOpenAPISchema };
|
|
92
|
+
//# sourceMappingURL=chunk-UCL7MHBL.js.map
|
|
93
|
+
//# sourceMappingURL=chunk-UCL7MHBL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/@standard-community+standard-openapi@0.2.9_@standard-community+standard-json@0.3.5_@sta_d040a6944a3a4ac0b81f62afd97a798c/node_modules/@standard-community/standard-openapi/dist/vendors/convert.js"],"names":[],"mappings":";AAAA,SAAS,sBAAA,CAAuB,YAAY,OAAA,EAAS;AACnD,EAAA,MAAM,cAAc,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,SAAA,CAAU,UAAU,CAAC,CAAA;AACzD,EAAA,IAAI,UAAA,IAAc,WAAA,IAAe,WAAA,CAAY,QAAA,KAAa,IAAA,EAAM;AAC9D,IAAA,IAAI,YAAY,IAAA,EAAM;AACpB,MAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,WAAA,CAAY,IAAI,CAAA,EAAG;AACnC,QAAA,IAAI,CAAC,WAAA,CAAY,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA,EAAG;AACtC,UAAA,WAAA,CAAY,IAAA,CAAK,KAAK,MAAM,CAAA;AAAA,QAC9B;AAAA,MACF,CAAA,MAAO;AACL,QAAA,WAAA,CAAY,IAAA,GAAO,CAAC,WAAA,CAAY,IAAA,EAAM,MAAM,CAAA;AAAA,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AA,EAAI;AAChC,IAAA,OAAA,CAAQ,WAAW,OAAA,GAAU;AAAA,MAC3B,GAAG,QAAQ,UAAA,CAAW,OAAA;AAAA,MACtB,GAAG;AAAA,KACL;AACA,IAAA,OAAO;AAAA,MACL,IAAA,EAAM,wBAAwB,GAAG,CAAA;AAAA,KACnC;AAAA,EACF;AACA,EAAA,OAAO,WAAA;AACT","file":"chunk-UCL7MHBL.js","sourcesContent":["function convertToOpenAPISchema(jsonSchema, context) {\n const _jsonSchema = JSON.parse(JSON.stringify(jsonSchema));\n if (\"nullable\" in _jsonSchema && _jsonSchema.nullable === true) {\n if (_jsonSchema.type) {\n if (Array.isArray(_jsonSchema.type)) {\n if (!_jsonSchema.type.includes(\"null\")) {\n _jsonSchema.type.push(\"null\");\n }\n } else {\n _jsonSchema.type = [_jsonSchema.type, \"null\"];\n }\n } else {\n _jsonSchema.type = [\"null\"];\n }\n delete _jsonSchema.nullable;\n }\n if (_jsonSchema.$schema) {\n delete _jsonSchema.$schema;\n }\n const nestedSchemaKeys = [\n \"properties\",\n \"additionalProperties\",\n \"items\",\n \"additionalItems\",\n \"allOf\",\n \"anyOf\",\n \"oneOf\",\n \"not\",\n \"if\",\n \"then\",\n \"else\",\n \"definitions\",\n \"$defs\",\n \"patternProperties\",\n \"propertyNames\",\n \"contains\"\n // \"unevaluatedProperties\",\n // \"unevaluatedItems\",\n ];\n nestedSchemaKeys.forEach((key) => {\n if (_jsonSchema[key] && (typeof _jsonSchema[key] === \"object\" || Array.isArray(_jsonSchema[key]))) {\n if (key === \"properties\" || key === \"definitions\" || key === \"$defs\" || key === \"patternProperties\") {\n for (const subKey in _jsonSchema[key]) {\n _jsonSchema[key][subKey] = convertToOpenAPISchema(\n _jsonSchema[key][subKey],\n context\n );\n }\n } else if (key === \"allOf\" || key === \"anyOf\" || key === \"oneOf\") {\n _jsonSchema[key] = _jsonSchema[key].map(\n (item) => convertToOpenAPISchema(item, context)\n );\n } else if (key === \"items\") {\n if (Array.isArray(_jsonSchema[key])) {\n _jsonSchema[key] = _jsonSchema[key].map(\n (item) => convertToOpenAPISchema(item, context)\n );\n } else {\n _jsonSchema[key] = convertToOpenAPISchema(_jsonSchema[key], context);\n }\n } else {\n _jsonSchema[key] = convertToOpenAPISchema(_jsonSchema[key], context);\n }\n }\n });\n if (_jsonSchema.ref || _jsonSchema.$id) {\n const { ref, $id, ...component } = _jsonSchema;\n const id = ref || $id;\n context.components.schemas = {\n ...context.components.schemas,\n [id]: component\n };\n return {\n $ref: `#/components/schemas/${id}`\n };\n } else if (_jsonSchema.$ref) {\n const { $ref, $defs } = _jsonSchema;\n const ref = $ref.split(\"/\").pop();\n context.components.schemas = {\n ...context.components.schemas,\n ...$defs\n };\n return {\n $ref: `#/components/schemas/${ref}`\n };\n }\n return _jsonSchema;\n}\n\nexport { convertToOpenAPISchema };\n"]}
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkYIUDHDPS_cjs = require('./chunk-YIUDHDPS.cjs');
|
|
4
|
+
var url = require('url');
|
|
5
|
+
var rollupPlugin = require('@optimize-lodash/rollup-plugin');
|
|
6
|
+
var commonjs = require('@rollup/plugin-commonjs');
|
|
7
|
+
var json = require('@rollup/plugin-json');
|
|
8
|
+
var rollup = require('rollup');
|
|
9
|
+
var babel = require('@babel/core');
|
|
10
|
+
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
function _interopNamespace(e) {
|
|
14
|
+
if (e && e.__esModule) return e;
|
|
15
|
+
var n = Object.create(null);
|
|
16
|
+
if (e) {
|
|
17
|
+
Object.keys(e).forEach(function (k) {
|
|
18
|
+
if (k !== 'default') {
|
|
19
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
20
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return e[k]; }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
n.default = e;
|
|
28
|
+
return Object.freeze(n);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
|
|
32
|
+
var json__default = /*#__PURE__*/_interopDefault(json);
|
|
33
|
+
var babel__namespace = /*#__PURE__*/_interopNamespace(babel);
|
|
34
|
+
|
|
35
|
+
function removeAllOptionsFromMastraExcept(result, option, logger) {
|
|
36
|
+
const t = babel__namespace.default.types;
|
|
37
|
+
return {
|
|
38
|
+
name: "remove-all-except-" + option + "-config",
|
|
39
|
+
visitor: {
|
|
40
|
+
ExportNamedDeclaration: {
|
|
41
|
+
// remove all exports
|
|
42
|
+
exit(path) {
|
|
43
|
+
path.remove();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
NewExpression(path, state) {
|
|
47
|
+
const varDeclaratorPath = path.findParent((path2) => t.isVariableDeclarator(path2.node));
|
|
48
|
+
if (!varDeclaratorPath) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const parentNode = path.parentPath.node;
|
|
52
|
+
if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let mastraArgs = t.objectExpression([]);
|
|
56
|
+
if (t.isObjectExpression(path.node.arguments[0])) {
|
|
57
|
+
mastraArgs = path.node.arguments[0];
|
|
58
|
+
}
|
|
59
|
+
let configProperty = mastraArgs.properties.find(
|
|
60
|
+
(prop) => t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === option
|
|
61
|
+
);
|
|
62
|
+
let configValue = t.objectExpression([]);
|
|
63
|
+
const programPath = path.scope.getProgramParent().path;
|
|
64
|
+
if (!programPath) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (configProperty && t.isObjectProperty(configProperty) && t.isExpression(configProperty.value)) {
|
|
68
|
+
result.hasCustomConfig = true;
|
|
69
|
+
configValue = configProperty.value;
|
|
70
|
+
if (t.isIdentifier(configProperty.value) && configProperty.value.name === option) {
|
|
71
|
+
const configBinding = state.file.scope.getBinding(option);
|
|
72
|
+
if (configBinding && t.isVariableDeclarator(configBinding.path.node)) {
|
|
73
|
+
const id = path.scope.generateUidIdentifier(option);
|
|
74
|
+
configBinding.path.replaceWith(t.variableDeclarator(id, configBinding.path.node.init));
|
|
75
|
+
configValue = id;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const exportDeclaration = t.exportNamedDeclaration(
|
|
80
|
+
t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), configValue)]),
|
|
81
|
+
[]
|
|
82
|
+
);
|
|
83
|
+
programPath.node.body.push(exportDeclaration);
|
|
84
|
+
},
|
|
85
|
+
Program: {
|
|
86
|
+
exit(path) {
|
|
87
|
+
const hasExport = path.node.body.some(
|
|
88
|
+
(node) => node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration"
|
|
89
|
+
);
|
|
90
|
+
if (!hasExport) {
|
|
91
|
+
if (logger) {
|
|
92
|
+
logger.warn(`Mastra ${option} config could not be extracted. Please make sure your entry file looks like this:
|
|
93
|
+
export const mastra = new Mastra({
|
|
94
|
+
${option}: <value>
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
`);
|
|
98
|
+
}
|
|
99
|
+
const fallbackExportDeclaration = t.exportNamedDeclaration(
|
|
100
|
+
t.variableDeclaration("const", [t.variableDeclarator(t.identifier(option), t.objectExpression([]))]),
|
|
101
|
+
[]
|
|
102
|
+
);
|
|
103
|
+
path.node.body.push(fallbackExportDeclaration);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/build/plugins/remove-all-except.ts
|
|
112
|
+
function removeAllOptionsFromMastraExceptPlugin(mastraEntry, name, result, options) {
|
|
113
|
+
return {
|
|
114
|
+
name: `remove-${name}`,
|
|
115
|
+
transform(code, id) {
|
|
116
|
+
if (id !== mastraEntry) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
return new Promise((resolve, reject) => {
|
|
120
|
+
babel__namespace.transform(
|
|
121
|
+
code,
|
|
122
|
+
{
|
|
123
|
+
babelrc: false,
|
|
124
|
+
configFile: false,
|
|
125
|
+
filename: id,
|
|
126
|
+
plugins: [removeAllOptionsFromMastraExcept(result, name, options?.logger)],
|
|
127
|
+
sourceMaps: options?.sourcemap
|
|
128
|
+
},
|
|
129
|
+
(err, result2) => {
|
|
130
|
+
if (err) {
|
|
131
|
+
return reject(err);
|
|
132
|
+
}
|
|
133
|
+
resolve({
|
|
134
|
+
code: result2.code,
|
|
135
|
+
map: result2.map
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function removeNonReferencedNodes() {
|
|
144
|
+
const t = babel__namespace.default.types;
|
|
145
|
+
return {
|
|
146
|
+
name: "remove-non-referenced-nodes",
|
|
147
|
+
visitor: {
|
|
148
|
+
Program(path) {
|
|
149
|
+
const scope = path.scope;
|
|
150
|
+
const currentBody = path.get("body");
|
|
151
|
+
const filteredBody = currentBody.filter((childPath) => {
|
|
152
|
+
if (childPath.isExportDeclaration()) {
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
if (childPath.isVariableDeclaration()) {
|
|
156
|
+
return childPath.node.declarations.some((decl) => {
|
|
157
|
+
if (!t.isIdentifier(decl.id)) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
const name = decl.id.name;
|
|
161
|
+
const binding = scope.getBinding(name);
|
|
162
|
+
return binding && (binding.referenced || binding.referencePaths.length > 0);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (childPath.isFunctionDeclaration() || childPath.isClassDeclaration()) {
|
|
166
|
+
if (!t.isIdentifier(childPath.node.id)) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
const name = childPath.node.id.name;
|
|
170
|
+
const binding = scope.getBinding(name);
|
|
171
|
+
return binding && (binding.referenced || binding.referencePaths.length > 0);
|
|
172
|
+
}
|
|
173
|
+
if (childPath.isImportDeclaration()) {
|
|
174
|
+
return childPath.node.specifiers.some((specifier) => {
|
|
175
|
+
const importedName = specifier.local.name;
|
|
176
|
+
const binding = scope.getBinding(importedName);
|
|
177
|
+
return binding && (binding.referenced || binding.referencePaths.length > 0);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return false;
|
|
181
|
+
});
|
|
182
|
+
path.set(
|
|
183
|
+
"body",
|
|
184
|
+
filteredBody.map((p) => p.node)
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// src/build/plugins/remove-unused-references.ts
|
|
192
|
+
function recursiveRemoveNonReferencedNodes(code) {
|
|
193
|
+
return new Promise(async (resolve, reject) => {
|
|
194
|
+
babel__namespace.transform(
|
|
195
|
+
code,
|
|
196
|
+
{
|
|
197
|
+
babelrc: false,
|
|
198
|
+
configFile: false,
|
|
199
|
+
plugins: [removeNonReferencedNodes()]
|
|
200
|
+
},
|
|
201
|
+
(err, result) => {
|
|
202
|
+
if (err) {
|
|
203
|
+
return reject(err);
|
|
204
|
+
}
|
|
205
|
+
if (result && result.code !== code) {
|
|
206
|
+
return recursiveRemoveNonReferencedNodes(result.code).then(resolve, reject);
|
|
207
|
+
}
|
|
208
|
+
resolve({
|
|
209
|
+
code: result.code,
|
|
210
|
+
map: result.map
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/build/shared/extract-mastra-option.ts
|
|
218
|
+
function extractMastraOptionBundler(name, entryFile, result, logger) {
|
|
219
|
+
return rollup.rollup({
|
|
220
|
+
logLevel: "silent",
|
|
221
|
+
input: {
|
|
222
|
+
[`${name}-config`]: entryFile
|
|
223
|
+
},
|
|
224
|
+
treeshake: "smallest",
|
|
225
|
+
plugins: [
|
|
226
|
+
chunkYIUDHDPS_cjs.tsConfigPaths(),
|
|
227
|
+
// transpile typescript to something we understand
|
|
228
|
+
chunkYIUDHDPS_cjs.esbuild(),
|
|
229
|
+
rollupPlugin.optimizeLodashImports({
|
|
230
|
+
include: "**/*.{js,ts,mjs,cjs}"
|
|
231
|
+
}),
|
|
232
|
+
commonjs__default.default({
|
|
233
|
+
extensions: [".js", ".ts"],
|
|
234
|
+
strictRequires: "strict",
|
|
235
|
+
transformMixedEsModules: true,
|
|
236
|
+
ignoreTryCatch: false
|
|
237
|
+
}),
|
|
238
|
+
json__default.default(),
|
|
239
|
+
removeAllOptionsFromMastraExceptPlugin(entryFile, name, result, { logger }),
|
|
240
|
+
// let esbuild remove all unused imports
|
|
241
|
+
chunkYIUDHDPS_cjs.esbuild(),
|
|
242
|
+
{
|
|
243
|
+
name: "cleanup",
|
|
244
|
+
transform(code, id) {
|
|
245
|
+
if (id !== entryFile) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
return recursiveRemoveNonReferencedNodes(code);
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
// let esbuild remove it once more
|
|
252
|
+
chunkYIUDHDPS_cjs.esbuild()
|
|
253
|
+
]
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
async function extractMastraOption(name, entryFile, outputDir, logger) {
|
|
257
|
+
const result = {
|
|
258
|
+
hasCustomConfig: false
|
|
259
|
+
};
|
|
260
|
+
const bundler = await extractMastraOptionBundler(name, entryFile, result, logger);
|
|
261
|
+
const output = await bundler.write({
|
|
262
|
+
dir: outputDir,
|
|
263
|
+
format: "es",
|
|
264
|
+
entryFileNames: "[name].mjs"
|
|
265
|
+
});
|
|
266
|
+
if (result.hasCustomConfig) {
|
|
267
|
+
const configPath = `${outputDir}/${name}-config.mjs`;
|
|
268
|
+
return {
|
|
269
|
+
bundleOutput: output,
|
|
270
|
+
getConfig: () => import(url.pathToFileURL(configPath).href).then((m) => m[name])
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// src/build/bundlerOptions.ts
|
|
277
|
+
async function getBundlerOptions(entryFile, outputDir, logger) {
|
|
278
|
+
const result = await extractMastraOption("bundler", entryFile, outputDir, logger);
|
|
279
|
+
if (!result) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
return result.getConfig();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
exports.extractMastraOption = extractMastraOption;
|
|
286
|
+
exports.getBundlerOptions = getBundlerOptions;
|
|
287
|
+
//# sourceMappingURL=chunk-UPVHAZ5Q.cjs.map
|
|
288
|
+
//# sourceMappingURL=chunk-UPVHAZ5Q.cjs.map
|