@mastra/deployer 0.2.5 → 0.2.6-alpha.10

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.
Files changed (40) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +95 -33
  2. package/dist/_tsup-dts-rollup.d.ts +95 -33
  3. package/dist/build/analyze.cjs +2 -2
  4. package/dist/build/analyze.js +1 -1
  5. package/dist/build/bundler.cjs +3 -3
  6. package/dist/build/bundler.js +1 -1
  7. package/dist/build/index.cjs +22 -24
  8. package/dist/build/index.d.cts +3 -4
  9. package/dist/build/index.d.ts +3 -4
  10. package/dist/build/index.js +6 -4
  11. package/dist/bundler/index.cjs +2 -2
  12. package/dist/bundler/index.js +1 -1
  13. package/dist/chunk-2ZPQX6BX.cjs +254 -0
  14. package/dist/chunk-4AYFLP6G.js +227 -0
  15. package/dist/chunk-5UBGPRKT.js +185 -0
  16. package/dist/{chunk-KLVSED7T.js → chunk-74KZVNKH.js} +8 -4
  17. package/dist/{chunk-OT6UKL2S.cjs → chunk-AE4CVAPK.cjs} +11 -0
  18. package/dist/{chunk-UTZ3434D.js → chunk-BDTZS3JM.js} +3 -0
  19. package/dist/chunk-DYQ225MJ.js +115 -0
  20. package/dist/chunk-I3UVE6EH.cjs +161 -0
  21. package/dist/{chunk-XEFBJH3T.js → chunk-IKPL4RGG.js} +11 -0
  22. package/dist/chunk-NCROGJGB.cjs +142 -0
  23. package/dist/{chunk-NWERLYTR.cjs → chunk-P5SATU7G.cjs} +3 -0
  24. package/dist/chunk-VFZVVUQE.cjs +198 -0
  25. package/dist/chunk-WB3T6NKI.js +133 -0
  26. package/dist/{chunk-NXBTVZHO.cjs → chunk-WFC3CUZ3.cjs} +14 -10
  27. package/dist/index.cjs +12 -11
  28. package/dist/index.js +7 -6
  29. package/dist/server/index.cjs +617 -2682
  30. package/dist/server/index.js +512 -2577
  31. package/dist/services/index.cjs +19 -0
  32. package/dist/services/index.d.cts +3 -0
  33. package/dist/services/index.d.ts +3 -0
  34. package/dist/services/index.js +2 -0
  35. package/dist/templates/instrumentation-template.js +25 -30
  36. package/package.json +15 -4
  37. package/dist/chunk-7GYBZLVN.cjs +0 -286
  38. package/dist/chunk-KFOGAPGX.cjs +0 -433
  39. package/dist/chunk-PUX2FDGX.js +0 -252
  40. package/dist/chunk-ZAXXMFXX.js +0 -399
@@ -0,0 +1,133 @@
1
+ import { recursiveRemoveNonReferencedNodes, removeAllOptionsFromMastraExcept } from './chunk-4AYFLP6G.js';
2
+ import { aliasHono } from './chunk-BDTZS3JM.js';
3
+ import { getInputOptions } from './chunk-IKPL4RGG.js';
4
+ import { watch, rollup } from 'rollup';
5
+ import * as babel from '@babel/core';
6
+ import esbuild from 'rollup-plugin-esbuild';
7
+ import commonjs from '@rollup/plugin-commonjs';
8
+
9
+ async function getInputOptions2(entryFile, platform) {
10
+ const inputOptions = await getInputOptions(
11
+ entryFile,
12
+ {
13
+ dependencies: /* @__PURE__ */ new Map(),
14
+ externalDependencies: /* @__PURE__ */ new Set(),
15
+ invalidChunks: /* @__PURE__ */ new Set()
16
+ },
17
+ platform
18
+ );
19
+ if (Array.isArray(inputOptions.plugins)) {
20
+ inputOptions.plugins = inputOptions.plugins.filter(
21
+ // @ts-ignore
22
+ (plugin) => !plugin || !plugin?.name || plugin.name !== "node-resolve"
23
+ );
24
+ inputOptions.plugins.push(aliasHono());
25
+ }
26
+ return inputOptions;
27
+ }
28
+ async function createWatcher(inputOptions, outputOptions) {
29
+ const watcher = await watch({
30
+ ...inputOptions,
31
+ output: {
32
+ ...outputOptions,
33
+ format: "esm",
34
+ entryFileNames: "[name].mjs",
35
+ chunkFileNames: "[name].mjs"
36
+ }
37
+ });
38
+ return watcher;
39
+ }
40
+
41
+ // src/build/babel/remove-all-options-server.ts
42
+ function removeAllOptionsExceptServer(result) {
43
+ return removeAllOptionsFromMastraExcept(result, "server");
44
+ }
45
+ function getServerOptionsBundler(entryFile, result) {
46
+ return rollup({
47
+ logLevel: "silent",
48
+ input: {
49
+ "server-config": entryFile
50
+ },
51
+ treeshake: "smallest",
52
+ plugins: [
53
+ // transpile typescript to something we understand
54
+ esbuild({
55
+ target: "node20",
56
+ platform: "node",
57
+ minify: false
58
+ }),
59
+ commonjs({
60
+ extensions: [".js", ".ts"],
61
+ strictRequires: "strict",
62
+ transformMixedEsModules: true,
63
+ ignoreTryCatch: false
64
+ }),
65
+ {
66
+ name: "get-server-config",
67
+ transform(code, id) {
68
+ if (id !== entryFile) {
69
+ return;
70
+ }
71
+ return new Promise((resolve, reject) => {
72
+ babel.transform(
73
+ code,
74
+ {
75
+ babelrc: false,
76
+ configFile: false,
77
+ filename: id,
78
+ plugins: [removeAllOptionsExceptServer(result)]
79
+ },
80
+ (err, result2) => {
81
+ if (err) {
82
+ return reject(err);
83
+ }
84
+ resolve({
85
+ code: result2.code,
86
+ map: result2.map
87
+ });
88
+ }
89
+ );
90
+ });
91
+ }
92
+ },
93
+ // let esbuild remove all unused imports
94
+ esbuild({
95
+ target: "node20",
96
+ platform: "node",
97
+ minify: false
98
+ }),
99
+ {
100
+ name: "cleanup",
101
+ transform(code, id) {
102
+ if (id !== entryFile) {
103
+ return;
104
+ }
105
+ return recursiveRemoveNonReferencedNodes(code);
106
+ }
107
+ },
108
+ // let esbuild remove all unused imports
109
+ esbuild({
110
+ target: "node20",
111
+ platform: "node",
112
+ minify: false
113
+ })
114
+ ]
115
+ });
116
+ }
117
+ async function getServerOptions(entryFile, outputDir) {
118
+ const result = {
119
+ hasCustomConfig: false
120
+ };
121
+ const bundle = await getServerOptionsBundler(entryFile, result);
122
+ await bundle.write({
123
+ dir: outputDir,
124
+ format: "es",
125
+ entryFileNames: "[name].mjs"
126
+ });
127
+ if (result.hasCustomConfig) {
128
+ return (await import(`file:${outputDir}/server-config.mjs`)).server;
129
+ }
130
+ return null;
131
+ }
132
+
133
+ export { createWatcher, getInputOptions2 as getInputOptions, getServerOptions };
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkKFOGAPGX_cjs = require('./chunk-KFOGAPGX.cjs');
4
- var chunkNWERLYTR_cjs = require('./chunk-NWERLYTR.cjs');
5
- var chunkOT6UKL2S_cjs = require('./chunk-OT6UKL2S.cjs');
3
+ var chunk2ZPQX6BX_cjs = require('./chunk-2ZPQX6BX.cjs');
4
+ var chunkP5SATU7G_cjs = require('./chunk-P5SATU7G.cjs');
5
+ var chunkAE4CVAPK_cjs = require('./chunk-AE4CVAPK.cjs');
6
+ var chunkVFZVVUQE_cjs = require('./chunk-VFZVVUQE.cjs');
6
7
  var fs = require('fs');
7
8
  var promises = require('fs/promises');
8
9
  var path = require('path');
@@ -31,7 +32,7 @@ var Bundler = class extends bundler.MastraBundler {
31
32
  }
32
33
  async writeInstrumentationFile(outputDirectory) {
33
34
  const instrumentationFile = path.join(outputDirectory, "instrumentation.mjs");
34
- 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-NXBTVZHO.cjs', document.baseURI).href))));
35
+ 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-WFC3CUZ3.cjs', document.baseURI).href))));
35
36
  await esm.copy(path.join(__dirname, "templates", "instrumentation-template.js"), instrumentationFile);
36
37
  }
37
38
  async writePackageJson(outputDirectory, dependencies) {
@@ -70,13 +71,13 @@ var Bundler = class extends bundler.MastraBundler {
70
71
  );
71
72
  }
72
73
  createBundler(inputOptions, outputOptions) {
73
- return chunkOT6UKL2S_cjs.createBundler(inputOptions, outputOptions);
74
+ return chunkAE4CVAPK_cjs.createBundler(inputOptions, outputOptions);
74
75
  }
75
76
  async analyze(entry, mastraFile, outputDirectory) {
76
- return await chunkNWERLYTR_cjs.analyzeBundle(entry, mastraFile, path.join(outputDirectory, this.analyzeOutputDir), "node", this.logger);
77
+ return await chunkP5SATU7G_cjs.analyzeBundle(entry, mastraFile, path.join(outputDirectory, this.analyzeOutputDir), "node", this.logger);
77
78
  }
78
79
  async installDependencies(outputDirectory, rootDir = process.cwd()) {
79
- const deps = new chunkKFOGAPGX_cjs.Deps(rootDir);
80
+ const deps = new chunkVFZVVUQE_cjs.DepsService(rootDir);
80
81
  deps.__setLogger(this.logger);
81
82
  await deps.install({ dir: path.join(outputDirectory, this.outputDir) });
82
83
  }
@@ -90,7 +91,7 @@ var Bundler = class extends bundler.MastraBundler {
90
91
  await esm.copy(publicDir, path.join(outputDirectory, this.outputDir));
91
92
  }
92
93
  async getBundlerOptions(serverFile, mastraEntryFile, analyzedBundleInfo) {
93
- const inputOptions = await chunkOT6UKL2S_cjs.getInputOptions(mastraEntryFile, analyzedBundleInfo, "node");
94
+ const inputOptions = await chunkAE4CVAPK_cjs.getInputOptions(mastraEntryFile, analyzedBundleInfo, "node");
94
95
  const isVirtual = serverFile.includes("\n") || fs.existsSync(serverFile);
95
96
  if (isVirtual) {
96
97
  inputOptions.input = { index: "#entry" };
@@ -106,14 +107,14 @@ var Bundler = class extends bundler.MastraBundler {
106
107
  }
107
108
  async _bundle(serverFile, mastraEntryFile, outputDirectory, bundleLocation = path.join(outputDirectory, this.outputDir)) {
108
109
  this.logger.info("Start bundling Mastra");
109
- const analyzedBundleInfo = await chunkNWERLYTR_cjs.analyzeBundle(
110
+ const analyzedBundleInfo = await chunkP5SATU7G_cjs.analyzeBundle(
110
111
  serverFile,
111
112
  mastraEntryFile,
112
113
  path.join(outputDirectory, this.analyzeOutputDir),
113
114
  "node",
114
115
  this.logger
115
116
  );
116
- await chunkKFOGAPGX_cjs.writeTelemetryConfig(mastraEntryFile, path.join(outputDirectory, this.outputDir));
117
+ await chunk2ZPQX6BX_cjs.writeTelemetryConfig(mastraEntryFile, path.join(outputDirectory, this.outputDir));
117
118
  const dependenciesToInstall = /* @__PURE__ */ new Map();
118
119
  for (const dep of analyzedBundleInfo.externalDependencies) {
119
120
  try {
@@ -124,6 +125,9 @@ var Bundler = class extends bundler.MastraBundler {
124
125
  dependenciesToInstall.set(dep, "latest");
125
126
  }
126
127
  }
128
+ if (analyzedBundleInfo.externalDependencies.has("@mastra/memory") || analyzedBundleInfo.dependencies.has("@mastra/memory")) {
129
+ dependenciesToInstall.set("fastembed", "latest");
130
+ }
127
131
  await this.writePackageJson(path.join(outputDirectory, this.outputDir), dependenciesToInstall);
128
132
  await this.writeInstrumentationFile(path.join(outputDirectory, this.outputDir));
129
133
  this.logger.info("Bundling Mastra application");
package/dist/index.cjs CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunk7GYBZLVN_cjs = require('./chunk-7GYBZLVN.cjs');
4
- var chunkNXBTVZHO_cjs = require('./chunk-NXBTVZHO.cjs');
5
- var chunkKFOGAPGX_cjs = require('./chunk-KFOGAPGX.cjs');
3
+ var chunkWFC3CUZ3_cjs = require('./chunk-WFC3CUZ3.cjs');
4
+ var chunk2ZPQX6BX_cjs = require('./chunk-2ZPQX6BX.cjs');
5
+ var chunkNCROGJGB_cjs = require('./chunk-NCROGJGB.cjs');
6
+ var chunkVFZVVUQE_cjs = require('./chunk-VFZVVUQE.cjs');
6
7
  var babel = require('@babel/core');
7
8
  var rollup = require('rollup');
8
9
  var esbuild = require('rollup-plugin-esbuild');
@@ -33,8 +34,8 @@ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
33
34
  var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
34
35
 
35
36
  // src/deploy/base.ts
36
- var Deployer = class extends chunkNXBTVZHO_cjs.Bundler {
37
- deps = new chunkKFOGAPGX_cjs.Deps();
37
+ var Deployer = class extends chunkWFC3CUZ3_cjs.Bundler {
38
+ deps = new chunkVFZVVUQE_cjs.DepsService();
38
39
  constructor(args) {
39
40
  super(args.name, "DEPLOYER");
40
41
  this.deps.__setLogger(this.logger);
@@ -42,7 +43,7 @@ var Deployer = class extends chunkNXBTVZHO_cjs.Bundler {
42
43
  getEnvFiles() {
43
44
  const possibleFiles = [".env.production", ".env.local", ".env"];
44
45
  try {
45
- const fileService = new chunk7GYBZLVN_cjs.FileService();
46
+ const fileService = new chunkNCROGJGB_cjs.FileService();
46
47
  const envFile = fileService.getFirstExistingFile(possibleFiles);
47
48
  return Promise.resolve([envFile]);
48
49
  } catch {
@@ -147,7 +148,7 @@ function getDeployerBundler(entryFile) {
147
148
  if (id !== entryFile) {
148
149
  return;
149
150
  }
150
- return chunkKFOGAPGX_cjs.recursiveRemoveNonReferencedNodes(code);
151
+ return chunk2ZPQX6BX_cjs.recursiveRemoveNonReferencedNodes(code);
151
152
  }
152
153
  },
153
154
  // let esbuild remove all unused imports
@@ -172,19 +173,19 @@ async function getDeployer(entryFile, outputDir) {
172
173
 
173
174
  Object.defineProperty(exports, "FileService", {
174
175
  enumerable: true,
175
- get: function () { return chunk7GYBZLVN_cjs.FileService; }
176
+ get: function () { return chunkNCROGJGB_cjs.FileService; }
176
177
  });
177
178
  Object.defineProperty(exports, "Deps", {
178
179
  enumerable: true,
179
- get: function () { return chunkKFOGAPGX_cjs.Deps; }
180
+ get: function () { return chunkVFZVVUQE_cjs.Deps; }
180
181
  });
181
182
  Object.defineProperty(exports, "createChildProcessLogger", {
182
183
  enumerable: true,
183
- get: function () { return chunkKFOGAPGX_cjs.createChildProcessLogger; }
184
+ get: function () { return chunkVFZVVUQE_cjs.createChildProcessLogger; }
184
185
  });
185
186
  Object.defineProperty(exports, "createPinoStream", {
186
187
  enumerable: true,
187
- get: function () { return chunkKFOGAPGX_cjs.createPinoStream; }
188
+ get: function () { return chunkVFZVVUQE_cjs.createPinoStream; }
188
189
  });
189
190
  exports.Deployer = Deployer;
190
191
  exports.getDeployer = getDeployer;
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
- import { FileService } from './chunk-PUX2FDGX.js';
2
- export { FileService } from './chunk-PUX2FDGX.js';
3
- import { Bundler } from './chunk-KLVSED7T.js';
4
- import { Deps, recursiveRemoveNonReferencedNodes } from './chunk-ZAXXMFXX.js';
5
- export { Deps, createChildProcessLogger, createPinoStream } from './chunk-ZAXXMFXX.js';
1
+ import { Bundler } from './chunk-74KZVNKH.js';
2
+ import { recursiveRemoveNonReferencedNodes } from './chunk-4AYFLP6G.js';
3
+ import { FileService } from './chunk-DYQ225MJ.js';
4
+ export { FileService } from './chunk-DYQ225MJ.js';
5
+ import { DepsService } from './chunk-5UBGPRKT.js';
6
+ export { Deps, createChildProcessLogger, createPinoStream } from './chunk-5UBGPRKT.js';
6
7
  import * as babel from '@babel/core';
7
8
  import babel__default from '@babel/core';
8
9
  import { rollup } from 'rollup';
@@ -11,7 +12,7 @@ import commonjs from '@rollup/plugin-commonjs';
11
12
 
12
13
  // src/deploy/base.ts
13
14
  var Deployer = class extends Bundler {
14
- deps = new Deps();
15
+ deps = new DepsService();
15
16
  constructor(args) {
16
17
  super(args.name, "DEPLOYER");
17
18
  this.deps.__setLogger(this.logger);