@mastra/deployer 0.0.0-declaration-maps-20250729231921 → 0.0.0-declaration-maps-20250730185206
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/build/analyze.cjs +12 -0
- package/dist/build/analyze.cjs.map +1 -0
- package/dist/build/analyze.js +3 -0
- package/dist/build/analyze.js.map +1 -0
- package/dist/build/bundler.cjs +16 -0
- package/dist/build/bundler.cjs.map +1 -0
- package/dist/build/bundler.d.ts.map +1 -1
- package/dist/build/bundler.js +3 -0
- package/dist/build/bundler.js.map +1 -0
- package/dist/build/index.cjs +52 -0
- package/dist/build/index.cjs.map +1 -0
- package/dist/build/index.js +7 -0
- package/dist/build/index.js.map +1 -0
- package/dist/bundler/index.cjs +12 -0
- package/dist/bundler/index.cjs.map +1 -0
- package/dist/bundler/index.js +3 -0
- package/dist/bundler/index.js.map +1 -0
- package/dist/chunk-2UXLNUIH.cjs +530 -0
- package/dist/chunk-2UXLNUIH.cjs.map +1 -0
- package/dist/chunk-37Q52RJU.js +376 -0
- package/dist/chunk-37Q52RJU.js.map +1 -0
- package/dist/chunk-AVHNLB72.cjs +4 -0
- package/dist/chunk-AVHNLB72.cjs.map +1 -0
- package/dist/chunk-DESEJA4T.js +3 -0
- package/dist/chunk-DESEJA4T.js.map +1 -0
- package/dist/chunk-HCS3GDEA.js +107 -0
- package/dist/chunk-HCS3GDEA.js.map +1 -0
- package/dist/chunk-J4SL7224.cjs +408 -0
- package/dist/chunk-J4SL7224.cjs.map +1 -0
- package/dist/chunk-JB6FHFGN.js +518 -0
- package/dist/chunk-JB6FHFGN.js.map +1 -0
- package/dist/chunk-LKOX6TV2.cjs +253 -0
- package/dist/chunk-LKOX6TV2.cjs.map +1 -0
- package/dist/chunk-OGRE3WLX.js +224 -0
- package/dist/chunk-OGRE3WLX.js.map +1 -0
- package/dist/chunk-OOVC5E4J.js +155 -0
- package/dist/chunk-OOVC5E4J.js.map +1 -0
- package/dist/chunk-UGGYWHCV.cjs +133 -0
- package/dist/chunk-UGGYWHCV.cjs.map +1 -0
- package/dist/chunk-VAE7BL7I.cjs +182 -0
- package/dist/chunk-VAE7BL7I.cjs.map +1 -0
- package/dist/chunk-WZSL63LO.js +150 -0
- package/dist/chunk-WZSL63LO.js.map +1 -0
- package/dist/chunk-YEAHZONX.cjs +631 -0
- package/dist/chunk-YEAHZONX.cjs.map +1 -0
- package/dist/chunk-YFOBFV3D.cjs +161 -0
- package/dist/chunk-YFOBFV3D.cjs.map +1 -0
- package/dist/chunk-ZR763P5C.js +599 -0
- package/dist/chunk-ZR763P5C.js.map +1 -0
- package/dist/index.cjs +35 -1865
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -1847
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +9660 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.js +9651 -0
- package/dist/server/index.js.map +1 -0
- package/dist/services/index.cjs +20 -0
- package/dist/services/index.cjs.map +1 -0
- package/dist/services/index.js +3 -0
- package/dist/services/index.js.map +1 -0
- package/dist/templates/instrumentation-template.js +143 -0
- package/dist/validator/custom-resolver.cjs +54 -0
- package/dist/validator/custom-resolver.cjs.map +1 -0
- package/dist/validator/custom-resolver.js +52 -0
- package/dist/validator/custom-resolver.js.map +1 -0
- package/dist/validator/loader.cjs +9 -0
- package/dist/validator/loader.cjs.map +1 -0
- package/dist/validator/loader.js +6 -0
- package/dist/validator/loader.js.map +1 -0
- package/package.json +8 -7
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkYEAHZONX_cjs = require('../chunk-YEAHZONX.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "analyzeBundle", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkYEAHZONX_cjs.analyzeBundle; }
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=analyze.cjs.map
|
|
12
|
+
//# sourceMappingURL=analyze.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"analyze.cjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"analyze.js"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkYFOBFV3D_cjs = require('../chunk-YFOBFV3D.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "createBundler", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkYFOBFV3D_cjs.createBundler; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "getInputOptions", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkYFOBFV3D_cjs.getInputOptions; }
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=bundler.cjs.map
|
|
16
|
+
//# sourceMappingURL=bundler.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"bundler.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../src/build/bundler.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"bundler.d.ts","sourceRoot":"","sources":["../../src/build/bundler.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAIvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI/C,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,EAC7D,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAA4D,EACtF,EAAE,SAAiB,EAAE,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GAClD,OAAO,CAAC,YAAY,CAAC,CAgIvB;AAED,wBAAsB,aAAa,CACjC,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE;;;GAiBxD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"bundler.js"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkLKOX6TV2_cjs = require('../chunk-LKOX6TV2.cjs');
|
|
4
|
+
var chunkUGGYWHCV_cjs = require('../chunk-UGGYWHCV.cjs');
|
|
5
|
+
var chunkYEAHZONX_cjs = require('../chunk-YEAHZONX.cjs');
|
|
6
|
+
var chunkYFOBFV3D_cjs = require('../chunk-YFOBFV3D.cjs');
|
|
7
|
+
var chunkJ4SL7224_cjs = require('../chunk-J4SL7224.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Object.defineProperty(exports, "createWatcher", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkLKOX6TV2_cjs.createWatcher; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "getServerOptions", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkLKOX6TV2_cjs.getServerOptions; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "getWatcherInputOptions", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkLKOX6TV2_cjs.getInputOptions; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "writeTelemetryConfig", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkUGGYWHCV_cjs.writeTelemetryConfig; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "analyzeBundle", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkYEAHZONX_cjs.analyzeBundle; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "getBundlerOptions", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunkYEAHZONX_cjs.getBundlerOptions; }
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "createBundler", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return chunkYFOBFV3D_cjs.createBundler; }
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(exports, "getBundlerInputOptions", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get: function () { return chunkYFOBFV3D_cjs.getInputOptions; }
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "Deps", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return chunkJ4SL7224_cjs.Deps; }
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(exports, "FileService", {
|
|
48
|
+
enumerable: true,
|
|
49
|
+
get: function () { return chunkJ4SL7224_cjs.FileService; }
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=index.cjs.map
|
|
52
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { createWatcher, getServerOptions, getInputOptions as getWatcherInputOptions } from '../chunk-OGRE3WLX.js';
|
|
2
|
+
export { writeTelemetryConfig } from '../chunk-HCS3GDEA.js';
|
|
3
|
+
export { analyzeBundle, getBundlerOptions } from '../chunk-ZR763P5C.js';
|
|
4
|
+
export { createBundler, getInputOptions as getBundlerInputOptions } from '../chunk-WZSL63LO.js';
|
|
5
|
+
export { Deps, FileService } from '../chunk-37Q52RJU.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk2UXLNUIH_cjs = require('../chunk-2UXLNUIH.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "Bundler", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunk2UXLNUIH_cjs.Bundler; }
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=index.cjs.map
|
|
12
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkUGGYWHCV_cjs = require('./chunk-UGGYWHCV.cjs');
|
|
4
|
+
var chunkYEAHZONX_cjs = require('./chunk-YEAHZONX.cjs');
|
|
5
|
+
var chunkYFOBFV3D_cjs = require('./chunk-YFOBFV3D.cjs');
|
|
6
|
+
var chunkJ4SL7224_cjs = require('./chunk-J4SL7224.cjs');
|
|
7
|
+
var fs = require('fs');
|
|
8
|
+
var promises = require('fs/promises');
|
|
9
|
+
var path = require('path');
|
|
10
|
+
var url = require('url');
|
|
11
|
+
var bundler = require('@mastra/core/bundler');
|
|
12
|
+
var error = require('@mastra/core/error');
|
|
13
|
+
var virtual = require('@rollup/plugin-virtual');
|
|
14
|
+
var fsExtra = require('fs-extra/esm');
|
|
15
|
+
var globby = require('globby');
|
|
16
|
+
var resolveFrom = require('resolve-from');
|
|
17
|
+
var rollup = require('rollup');
|
|
18
|
+
var esbuild = require('rollup-plugin-esbuild');
|
|
19
|
+
var commonjs = require('@rollup/plugin-commonjs');
|
|
20
|
+
var slugify = require('@sindresorhus/slugify');
|
|
21
|
+
var findWorkspaces = require('find-workspaces');
|
|
22
|
+
var fsExtra$1 = require('fs-extra');
|
|
23
|
+
|
|
24
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
25
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
26
|
+
|
|
27
|
+
var virtual__default = /*#__PURE__*/_interopDefault(virtual);
|
|
28
|
+
var fsExtra__default = /*#__PURE__*/_interopDefault(fsExtra);
|
|
29
|
+
var resolveFrom__default = /*#__PURE__*/_interopDefault(resolveFrom);
|
|
30
|
+
var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
|
|
31
|
+
var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
|
|
32
|
+
var slugify__default = /*#__PURE__*/_interopDefault(slugify);
|
|
33
|
+
|
|
34
|
+
function getCustomInstrumentationBundler(entryFile, result) {
|
|
35
|
+
return rollup.rollup({
|
|
36
|
+
logLevel: "silent",
|
|
37
|
+
input: {
|
|
38
|
+
instrumentation: entryFile
|
|
39
|
+
},
|
|
40
|
+
treeshake: false,
|
|
41
|
+
plugins: [
|
|
42
|
+
// transpile typescript to something we understand
|
|
43
|
+
esbuild__default.default({
|
|
44
|
+
target: "node20",
|
|
45
|
+
platform: "node",
|
|
46
|
+
minify: false
|
|
47
|
+
}),
|
|
48
|
+
commonjs__default.default({
|
|
49
|
+
extensions: [".js", ".ts"],
|
|
50
|
+
strictRequires: "strict",
|
|
51
|
+
transformMixedEsModules: true,
|
|
52
|
+
ignoreTryCatch: false
|
|
53
|
+
})
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async function writeCustomInstrumentation(entryFile, outputDir, options = {}) {
|
|
58
|
+
const result = {
|
|
59
|
+
hasCustomConfig: false
|
|
60
|
+
};
|
|
61
|
+
const bundle = await getCustomInstrumentationBundler(entryFile);
|
|
62
|
+
const { output } = await bundle.write({
|
|
63
|
+
dir: outputDir,
|
|
64
|
+
format: "es",
|
|
65
|
+
entryFileNames: "[name].mjs",
|
|
66
|
+
sourcemap: options.sourcemap
|
|
67
|
+
});
|
|
68
|
+
const externals = output[0].imports.filter((x) => !x.startsWith("./"));
|
|
69
|
+
return { ...result, externalDependencies: externals };
|
|
70
|
+
}
|
|
71
|
+
var createWorkspacePackageMap = async () => {
|
|
72
|
+
const workspaces = await findWorkspaces.findWorkspaces();
|
|
73
|
+
const workspaceMap = new Map(
|
|
74
|
+
workspaces?.map((workspace) => [
|
|
75
|
+
workspace.package.name,
|
|
76
|
+
{
|
|
77
|
+
location: workspace.location,
|
|
78
|
+
dependencies: workspace.package.dependencies,
|
|
79
|
+
version: workspace.package.version
|
|
80
|
+
}
|
|
81
|
+
]) ?? []
|
|
82
|
+
);
|
|
83
|
+
return workspaceMap;
|
|
84
|
+
};
|
|
85
|
+
var collectTransitiveWorkspaceDependencies = ({
|
|
86
|
+
workspaceMap,
|
|
87
|
+
initialDependencies,
|
|
88
|
+
logger
|
|
89
|
+
}) => {
|
|
90
|
+
const usedWorkspacePackages = /* @__PURE__ */ new Set();
|
|
91
|
+
const queue = Array.from(initialDependencies);
|
|
92
|
+
const resolutions = {};
|
|
93
|
+
while (queue.length > 0) {
|
|
94
|
+
const len = queue.length;
|
|
95
|
+
for (let i = 0; i < len; i += 1) {
|
|
96
|
+
const pkgName = queue.shift();
|
|
97
|
+
if (!pkgName || usedWorkspacePackages.has(pkgName)) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const dep = workspaceMap.get(pkgName);
|
|
101
|
+
if (!dep) continue;
|
|
102
|
+
const root = findWorkspaces.findWorkspacesRoot();
|
|
103
|
+
if (!root) {
|
|
104
|
+
throw new Error("Could not find workspace root");
|
|
105
|
+
}
|
|
106
|
+
const depsService = new chunkJ4SL7224_cjs.DepsService(root.location);
|
|
107
|
+
depsService.__setLogger(logger);
|
|
108
|
+
const sanitizedName = slugify__default.default(pkgName);
|
|
109
|
+
const tgzPath = depsService.getWorkspaceDependencyPath({
|
|
110
|
+
pkgName: sanitizedName,
|
|
111
|
+
version: dep.version
|
|
112
|
+
});
|
|
113
|
+
resolutions[pkgName] = tgzPath;
|
|
114
|
+
usedWorkspacePackages.add(pkgName);
|
|
115
|
+
for (const [depName, _depVersion] of Object.entries(dep?.dependencies ?? {})) {
|
|
116
|
+
if (!usedWorkspacePackages.has(depName) && workspaceMap.has(depName)) {
|
|
117
|
+
queue.push(depName);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return { resolutions, usedWorkspacePackages };
|
|
123
|
+
};
|
|
124
|
+
var packWorkspaceDependencies = async ({
|
|
125
|
+
workspaceMap,
|
|
126
|
+
usedWorkspacePackages,
|
|
127
|
+
bundleOutputDir,
|
|
128
|
+
logger
|
|
129
|
+
}) => {
|
|
130
|
+
const root = findWorkspaces.findWorkspacesRoot();
|
|
131
|
+
if (!root) {
|
|
132
|
+
throw new Error("Could not find workspace root");
|
|
133
|
+
}
|
|
134
|
+
const depsService = new chunkJ4SL7224_cjs.DepsService(root.location);
|
|
135
|
+
depsService.__setLogger(logger);
|
|
136
|
+
if (usedWorkspacePackages.size > 0) {
|
|
137
|
+
const workspaceDirPath = path.join(bundleOutputDir, "workspace-module");
|
|
138
|
+
await fsExtra$1.ensureDir(workspaceDirPath);
|
|
139
|
+
logger.info(`Packaging ${usedWorkspacePackages.size} workspace dependencies...`);
|
|
140
|
+
const batchSize = 5;
|
|
141
|
+
const packages = Array.from(usedWorkspacePackages.values());
|
|
142
|
+
for (let i = 0; i < packages.length; i += batchSize) {
|
|
143
|
+
const batch = packages.slice(i, i + batchSize);
|
|
144
|
+
logger.info(
|
|
145
|
+
`Packaging batch ${Math.floor(i / batchSize) + 1}/${Math.ceil(packages.length / batchSize)}: ${batch.join(", ")}`
|
|
146
|
+
);
|
|
147
|
+
await Promise.all(
|
|
148
|
+
batch.map(async (pkgName) => {
|
|
149
|
+
const dep = workspaceMap.get(pkgName);
|
|
150
|
+
if (!dep) return;
|
|
151
|
+
await depsService.pack({ dir: dep.location, destination: workspaceDirPath });
|
|
152
|
+
})
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
logger.info(`Successfully packaged ${usedWorkspacePackages.size} workspace dependencies`);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// src/bundler/index.ts
|
|
160
|
+
var Bundler = class extends bundler.MastraBundler {
|
|
161
|
+
analyzeOutputDir = ".build";
|
|
162
|
+
outputDir = "output";
|
|
163
|
+
constructor(name, component = "BUNDLER") {
|
|
164
|
+
super({ name, component });
|
|
165
|
+
}
|
|
166
|
+
async prepare(outputDirectory) {
|
|
167
|
+
await fsExtra.emptyDir(outputDirectory);
|
|
168
|
+
await fsExtra.ensureDir(path.join(outputDirectory, this.analyzeOutputDir));
|
|
169
|
+
await fsExtra.ensureDir(path.join(outputDirectory, this.outputDir));
|
|
170
|
+
}
|
|
171
|
+
async writeInstrumentationFile(outputDirectory, customInstrumentationFile) {
|
|
172
|
+
const instrumentationFile = path.join(outputDirectory, "instrumentation.mjs");
|
|
173
|
+
const __dirname = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-2UXLNUIH.cjs', document.baseURI).href))));
|
|
174
|
+
if (customInstrumentationFile) {
|
|
175
|
+
await fsExtra.copy(customInstrumentationFile, instrumentationFile);
|
|
176
|
+
} else {
|
|
177
|
+
await fsExtra.copy(path.join(__dirname, "templates", "instrumentation-template.js"), instrumentationFile);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async writePackageJson(outputDirectory, dependencies, resolutions) {
|
|
181
|
+
this.logger.debug(`Writing project's package.json`);
|
|
182
|
+
await fsExtra.ensureDir(outputDirectory);
|
|
183
|
+
const pkgPath = path.join(outputDirectory, "package.json");
|
|
184
|
+
const dependenciesMap = /* @__PURE__ */ new Map();
|
|
185
|
+
for (const [key, value] of dependencies.entries()) {
|
|
186
|
+
if (key.startsWith("@")) {
|
|
187
|
+
const pkgChunks = key.split("/");
|
|
188
|
+
dependenciesMap.set(`${pkgChunks[0]}/${pkgChunks[1]}`, value);
|
|
189
|
+
} else {
|
|
190
|
+
const pkgName = key.split("/")[0] || key;
|
|
191
|
+
dependenciesMap.set(pkgName, value);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
dependenciesMap.set("@opentelemetry/core", "^2.0.1");
|
|
195
|
+
dependenciesMap.set("@opentelemetry/auto-instrumentations-node", "^0.59.0");
|
|
196
|
+
dependenciesMap.set("@opentelemetry/exporter-trace-otlp-grpc", "^0.201.0");
|
|
197
|
+
dependenciesMap.set("@opentelemetry/exporter-trace-otlp-http", "^0.201.0");
|
|
198
|
+
dependenciesMap.set("@opentelemetry/resources", "^2.0.1");
|
|
199
|
+
dependenciesMap.set("@opentelemetry/sdk-node", "^0.201.0");
|
|
200
|
+
dependenciesMap.set("@opentelemetry/sdk-trace-base", "^2.0.1");
|
|
201
|
+
dependenciesMap.set("@opentelemetry/semantic-conventions", "^1.33.0");
|
|
202
|
+
dependenciesMap.set("@opentelemetry/instrumentation", "^0.202.0");
|
|
203
|
+
await promises.writeFile(
|
|
204
|
+
pkgPath,
|
|
205
|
+
JSON.stringify(
|
|
206
|
+
{
|
|
207
|
+
name: "server",
|
|
208
|
+
version: "1.0.0",
|
|
209
|
+
description: "",
|
|
210
|
+
type: "module",
|
|
211
|
+
main: "index.mjs",
|
|
212
|
+
scripts: {
|
|
213
|
+
start: "node --import=./instrumentation.mjs --import=@opentelemetry/instrumentation/hook.mjs ./index.mjs"
|
|
214
|
+
},
|
|
215
|
+
author: "Mastra",
|
|
216
|
+
license: "ISC",
|
|
217
|
+
dependencies: Object.fromEntries(dependenciesMap.entries()),
|
|
218
|
+
...Object.keys(resolutions ?? {}).length > 0 && { resolutions },
|
|
219
|
+
pnpm: {
|
|
220
|
+
neverBuiltDependencies: []
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
null,
|
|
224
|
+
2
|
|
225
|
+
)
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
createBundler(inputOptions, outputOptions) {
|
|
229
|
+
return chunkYFOBFV3D_cjs.createBundler(inputOptions, outputOptions);
|
|
230
|
+
}
|
|
231
|
+
async analyze(entry, mastraFile, outputDirectory) {
|
|
232
|
+
return await chunkYEAHZONX_cjs.analyzeBundle(
|
|
233
|
+
[].concat(entry),
|
|
234
|
+
mastraFile,
|
|
235
|
+
path.join(outputDirectory, this.analyzeOutputDir),
|
|
236
|
+
"node",
|
|
237
|
+
this.logger
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
async installDependencies(outputDirectory, rootDir = process.cwd()) {
|
|
241
|
+
const deps = new chunkJ4SL7224_cjs.DepsService(rootDir);
|
|
242
|
+
deps.__setLogger(this.logger);
|
|
243
|
+
await deps.install({ dir: path.join(outputDirectory, this.outputDir) });
|
|
244
|
+
}
|
|
245
|
+
async copyPublic(mastraDir, outputDirectory) {
|
|
246
|
+
const publicDir = path.join(mastraDir, "public");
|
|
247
|
+
try {
|
|
248
|
+
await promises.stat(publicDir);
|
|
249
|
+
} catch {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
await fsExtra.copy(publicDir, path.join(outputDirectory, this.outputDir));
|
|
253
|
+
}
|
|
254
|
+
async copyDOTNPMRC({
|
|
255
|
+
rootDir = process.cwd(),
|
|
256
|
+
outputDirectory
|
|
257
|
+
}) {
|
|
258
|
+
const sourceDotNpmRcPath = path.join(rootDir, ".npmrc");
|
|
259
|
+
const targetDotNpmRcPath = path.join(outputDirectory, this.outputDir, ".npmrc");
|
|
260
|
+
try {
|
|
261
|
+
await promises.stat(sourceDotNpmRcPath);
|
|
262
|
+
await fsExtra.copy(sourceDotNpmRcPath, targetDotNpmRcPath);
|
|
263
|
+
} catch {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo, toolsPaths, sourcemapEnabled = false) {
|
|
268
|
+
const inputOptions = await chunkYFOBFV3D_cjs.getInputOptions(
|
|
269
|
+
mastraEntryFile,
|
|
270
|
+
analyzedBundleInfo,
|
|
271
|
+
"node",
|
|
272
|
+
{
|
|
273
|
+
"process.env.NODE_ENV": JSON.stringify("production")
|
|
274
|
+
},
|
|
275
|
+
{ sourcemap: sourcemapEnabled }
|
|
276
|
+
);
|
|
277
|
+
const isVirtual = serverFile.includes("\n") || fs.existsSync(serverFile);
|
|
278
|
+
const toolsInputOptions = await this.getToolsInputOptions(toolsPaths);
|
|
279
|
+
if (isVirtual) {
|
|
280
|
+
inputOptions.input = { index: "#entry", ...toolsInputOptions };
|
|
281
|
+
if (Array.isArray(inputOptions.plugins)) {
|
|
282
|
+
inputOptions.plugins.unshift(virtual__default.default({ "#entry": serverFile }));
|
|
283
|
+
} else {
|
|
284
|
+
inputOptions.plugins = [virtual__default.default({ "#entry": serverFile })];
|
|
285
|
+
}
|
|
286
|
+
} else {
|
|
287
|
+
inputOptions.input = { index: serverFile, ...toolsInputOptions };
|
|
288
|
+
}
|
|
289
|
+
return inputOptions;
|
|
290
|
+
}
|
|
291
|
+
async getToolsInputOptions(toolsPaths) {
|
|
292
|
+
const inputs = {};
|
|
293
|
+
for (const toolPath of toolsPaths) {
|
|
294
|
+
const expandedPaths = await globby.globby(toolPath, {});
|
|
295
|
+
for (const path$1 of expandedPaths) {
|
|
296
|
+
if (await fsExtra__default.default.pathExists(path$1)) {
|
|
297
|
+
const fileService = new chunkJ4SL7224_cjs.FileService();
|
|
298
|
+
const entryFile = fileService.getFirstExistingFile([
|
|
299
|
+
path.join(path$1, "index.ts"),
|
|
300
|
+
path.join(path$1, "index.js"),
|
|
301
|
+
path$1
|
|
302
|
+
// if path itself is a file
|
|
303
|
+
]);
|
|
304
|
+
if (!entryFile || (await promises.stat(entryFile)).isDirectory()) {
|
|
305
|
+
this.logger.warn(`No entry file found in ${path$1}, skipping...`);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
const uniqueToolID = crypto.randomUUID();
|
|
309
|
+
inputs[`tools/${uniqueToolID}`] = entryFile;
|
|
310
|
+
} else {
|
|
311
|
+
this.logger.warn(`Tool path ${path$1} does not exist, skipping...`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return inputs;
|
|
316
|
+
}
|
|
317
|
+
async _bundle(serverFile, mastraEntryFile, outputDirectory, toolsPaths = [], bundleLocation = path.join(outputDirectory, this.outputDir)) {
|
|
318
|
+
this.logger.info("Start bundling Mastra");
|
|
319
|
+
let sourcemap = false;
|
|
320
|
+
try {
|
|
321
|
+
const bundlerOptions = await chunkYEAHZONX_cjs.getBundlerOptions(mastraEntryFile, outputDirectory);
|
|
322
|
+
sourcemap = !!bundlerOptions?.sourcemap;
|
|
323
|
+
} catch (error) {
|
|
324
|
+
this.logger.debug("Failed to get bundler options, sourcemap will be disabled", { error });
|
|
325
|
+
}
|
|
326
|
+
let analyzedBundleInfo;
|
|
327
|
+
try {
|
|
328
|
+
const resolvedToolsPaths = await this.getToolsInputOptions(toolsPaths);
|
|
329
|
+
analyzedBundleInfo = await chunkYEAHZONX_cjs.analyzeBundle(
|
|
330
|
+
[serverFile, ...Object.values(resolvedToolsPaths)],
|
|
331
|
+
mastraEntryFile,
|
|
332
|
+
path.join(outputDirectory, this.analyzeOutputDir),
|
|
333
|
+
"node",
|
|
334
|
+
this.logger,
|
|
335
|
+
sourcemap
|
|
336
|
+
);
|
|
337
|
+
} catch (error$1) {
|
|
338
|
+
const message = error$1 instanceof Error ? error$1.message : String(error$1);
|
|
339
|
+
throw new error.MastraError(
|
|
340
|
+
{
|
|
341
|
+
id: "DEPLOYER_BUNDLER_ANALYZE_FAILED",
|
|
342
|
+
text: `Failed to analyze Mastra application: ${message}`,
|
|
343
|
+
domain: error.ErrorDomain.DEPLOYER,
|
|
344
|
+
category: error.ErrorCategory.SYSTEM
|
|
345
|
+
},
|
|
346
|
+
error$1
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
let externalDependencies;
|
|
350
|
+
try {
|
|
351
|
+
const result = await chunkUGGYWHCV_cjs.writeTelemetryConfig({
|
|
352
|
+
entryFile: mastraEntryFile,
|
|
353
|
+
outputDir: path.join(outputDirectory, this.outputDir),
|
|
354
|
+
options: {
|
|
355
|
+
sourcemap
|
|
356
|
+
},
|
|
357
|
+
logger: this.logger
|
|
358
|
+
});
|
|
359
|
+
externalDependencies = result.externalDependencies;
|
|
360
|
+
} catch (error$1) {
|
|
361
|
+
const message = error$1 instanceof Error ? error$1.message : String(error$1);
|
|
362
|
+
throw new error.MastraError(
|
|
363
|
+
{
|
|
364
|
+
id: "DEPLOYER_BUNDLER_TELEMETRY_FAILED",
|
|
365
|
+
text: `Failed to write telemetry config: ${message}`,
|
|
366
|
+
domain: error.ErrorDomain.DEPLOYER,
|
|
367
|
+
category: error.ErrorCategory.SYSTEM
|
|
368
|
+
},
|
|
369
|
+
error$1
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
const mastraFolder = path.dirname(mastraEntryFile);
|
|
373
|
+
const fileService = new chunkJ4SL7224_cjs.FileService();
|
|
374
|
+
const customInstrumentation = fileService.getFirstExistingFileOrUndefined([
|
|
375
|
+
path.join(mastraFolder, "instrumentation.js"),
|
|
376
|
+
path.join(mastraFolder, "instrumentation.ts"),
|
|
377
|
+
path.join(mastraFolder, "instrumentation.mjs")
|
|
378
|
+
]);
|
|
379
|
+
try {
|
|
380
|
+
if (customInstrumentation) {
|
|
381
|
+
const result = await writeCustomInstrumentation(customInstrumentation, path.join(outputDirectory, this.outputDir), {
|
|
382
|
+
sourcemap
|
|
383
|
+
});
|
|
384
|
+
externalDependencies = [...externalDependencies, ...result.externalDependencies];
|
|
385
|
+
await this.writeInstrumentationFile(path.join(outputDirectory, this.outputDir), customInstrumentation);
|
|
386
|
+
} else {
|
|
387
|
+
await this.writeInstrumentationFile(path.join(outputDirectory, this.outputDir));
|
|
388
|
+
}
|
|
389
|
+
} catch (error$1) {
|
|
390
|
+
const message = error$1 instanceof Error ? error$1.message : String(error$1);
|
|
391
|
+
throw new error.MastraError(
|
|
392
|
+
{
|
|
393
|
+
id: "DEPLOYER_BUNDLER_INSTRUMENTATION_FILE_FAILED",
|
|
394
|
+
text: `Failed to write instrumentation file: ${message}, ${customInstrumentation ? ` Found custom instrumentation file: ${customInstrumentation}` : ""}`,
|
|
395
|
+
domain: error.ErrorDomain.DEPLOYER,
|
|
396
|
+
category: error.ErrorCategory.SYSTEM
|
|
397
|
+
},
|
|
398
|
+
error$1
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
const dependenciesToInstall = /* @__PURE__ */ new Map();
|
|
402
|
+
for (const external of externalDependencies) {
|
|
403
|
+
dependenciesToInstall.set(external, "latest");
|
|
404
|
+
}
|
|
405
|
+
const workspaceMap = await createWorkspacePackageMap();
|
|
406
|
+
const workspaceDependencies = /* @__PURE__ */ new Set();
|
|
407
|
+
for (const dep of analyzedBundleInfo.externalDependencies) {
|
|
408
|
+
try {
|
|
409
|
+
const pkgPath = resolveFrom__default.default(mastraEntryFile, `${dep}/package.json`);
|
|
410
|
+
const pkg = await fsExtra.readJSON(pkgPath);
|
|
411
|
+
if (workspaceMap.has(pkg.name)) {
|
|
412
|
+
workspaceDependencies.add(pkg.name);
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
dependenciesToInstall.set(dep, pkg.version);
|
|
416
|
+
} catch {
|
|
417
|
+
dependenciesToInstall.set(dep, "latest");
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
let resolutions = {};
|
|
421
|
+
if (workspaceDependencies.size > 0) {
|
|
422
|
+
try {
|
|
423
|
+
const result = collectTransitiveWorkspaceDependencies({
|
|
424
|
+
workspaceMap,
|
|
425
|
+
initialDependencies: workspaceDependencies,
|
|
426
|
+
logger: this.logger
|
|
427
|
+
});
|
|
428
|
+
resolutions = result.resolutions;
|
|
429
|
+
Object.entries(resolutions).forEach(([pkgName, tgzPath]) => {
|
|
430
|
+
dependenciesToInstall.set(pkgName, tgzPath);
|
|
431
|
+
});
|
|
432
|
+
await packWorkspaceDependencies({
|
|
433
|
+
workspaceMap,
|
|
434
|
+
usedWorkspacePackages: result.usedWorkspacePackages,
|
|
435
|
+
bundleOutputDir: path.join(outputDirectory, this.outputDir),
|
|
436
|
+
logger: this.logger
|
|
437
|
+
});
|
|
438
|
+
} catch (error$1) {
|
|
439
|
+
throw new error.MastraError(
|
|
440
|
+
{
|
|
441
|
+
id: "DEPLOYER_BUNDLER_WORKSPACE_DEPS_FAILED",
|
|
442
|
+
text: `Failed to collect and pack workspace dependencies.`,
|
|
443
|
+
domain: error.ErrorDomain.DEPLOYER,
|
|
444
|
+
category: error.ErrorCategory.USER
|
|
445
|
+
},
|
|
446
|
+
error$1
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
try {
|
|
451
|
+
await this.writePackageJson(path.join(outputDirectory, this.outputDir), dependenciesToInstall, resolutions);
|
|
452
|
+
this.logger.info("Bundling Mastra application");
|
|
453
|
+
const inputOptions = await this.getBundlerOptions(
|
|
454
|
+
serverFile,
|
|
455
|
+
mastraEntryFile,
|
|
456
|
+
analyzedBundleInfo,
|
|
457
|
+
toolsPaths,
|
|
458
|
+
sourcemap
|
|
459
|
+
);
|
|
460
|
+
const bundler = await this.createBundler(
|
|
461
|
+
{
|
|
462
|
+
...inputOptions,
|
|
463
|
+
logLevel: inputOptions.logLevel === "silent" ? "warn" : inputOptions.logLevel,
|
|
464
|
+
onwarn: (warning) => {
|
|
465
|
+
if (warning.code === "CIRCULAR_DEPENDENCY") {
|
|
466
|
+
if (warning.ids?.[0]?.includes("node_modules")) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
this.logger.warn(`Circular dependency found:
|
|
470
|
+
${warning.message.replace("Circular dependency: ", "")}`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
dir: bundleLocation,
|
|
476
|
+
manualChunks: {
|
|
477
|
+
mastra: ["#mastra"]
|
|
478
|
+
},
|
|
479
|
+
sourcemap
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
await bundler.write();
|
|
483
|
+
const toolImports = [];
|
|
484
|
+
const toolsExports = [];
|
|
485
|
+
Array.from(Object.keys(inputOptions.input || {})).filter((key) => key.startsWith("tools/")).forEach((key, index) => {
|
|
486
|
+
const toolExport = `tool${index}`;
|
|
487
|
+
toolImports.push(`import * as ${toolExport} from './${key}.mjs';`);
|
|
488
|
+
toolsExports.push(toolExport);
|
|
489
|
+
});
|
|
490
|
+
await promises.writeFile(
|
|
491
|
+
path.join(bundleLocation, "tools.mjs"),
|
|
492
|
+
`${toolImports.join("\n")}
|
|
493
|
+
|
|
494
|
+
export const tools = [${toolsExports.join(", ")}]`
|
|
495
|
+
);
|
|
496
|
+
this.logger.info("Bundling Mastra done");
|
|
497
|
+
this.logger.info("Copying public files");
|
|
498
|
+
await this.copyPublic(path.dirname(mastraEntryFile), outputDirectory);
|
|
499
|
+
this.logger.info("Done copying public files");
|
|
500
|
+
this.logger.info("Copying .npmrc file");
|
|
501
|
+
await this.copyDOTNPMRC({ outputDirectory });
|
|
502
|
+
this.logger.info("Done copying .npmrc file");
|
|
503
|
+
this.logger.info("Installing dependencies");
|
|
504
|
+
await this.installDependencies(outputDirectory);
|
|
505
|
+
this.logger.info("Done installing dependencies");
|
|
506
|
+
} catch (error$1) {
|
|
507
|
+
const message = error$1 instanceof Error ? error$1.message : String(error$1);
|
|
508
|
+
throw new error.MastraError(
|
|
509
|
+
{
|
|
510
|
+
id: "DEPLOYER_BUNDLER_BUNDLE_STAGE_FAILED",
|
|
511
|
+
text: `Failed during bundler bundle stage: ${message}`,
|
|
512
|
+
domain: error.ErrorDomain.DEPLOYER,
|
|
513
|
+
category: error.ErrorCategory.SYSTEM
|
|
514
|
+
},
|
|
515
|
+
error$1
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
async lint(_entryFile, _outputDirectory, toolsPaths) {
|
|
520
|
+
const toolsInputOptions = await this.getToolsInputOptions(toolsPaths);
|
|
521
|
+
const toolsLength = Object.keys(toolsInputOptions).length;
|
|
522
|
+
if (toolsLength > 0) {
|
|
523
|
+
this.logger.info(`Found ${toolsLength} ${toolsLength === 1 ? "tool" : "tools"}`);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
exports.Bundler = Bundler;
|
|
529
|
+
//# sourceMappingURL=chunk-2UXLNUIH.cjs.map
|
|
530
|
+
//# sourceMappingURL=chunk-2UXLNUIH.cjs.map
|