@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,19 @@
1
+ 'use strict';
2
+
3
+ var chunkNCROGJGB_cjs = require('../chunk-NCROGJGB.cjs');
4
+ var chunkVFZVVUQE_cjs = require('../chunk-VFZVVUQE.cjs');
5
+
6
+
7
+
8
+ Object.defineProperty(exports, "EnvService", {
9
+ enumerable: true,
10
+ get: function () { return chunkNCROGJGB_cjs.EnvService; }
11
+ });
12
+ Object.defineProperty(exports, "FileService", {
13
+ enumerable: true,
14
+ get: function () { return chunkNCROGJGB_cjs.FileService; }
15
+ });
16
+ Object.defineProperty(exports, "DepsService", {
17
+ enumerable: true,
18
+ get: function () { return chunkVFZVVUQE_cjs.DepsService; }
19
+ });
@@ -0,0 +1,3 @@
1
+ export { DepsService_alias_1 as DepsService } from '../_tsup-dts-rollup.cjs';
2
+ export { EnvService_alias_1 as EnvService } from '../_tsup-dts-rollup.cjs';
3
+ export { FileService_alias_3 as FileService } from '../_tsup-dts-rollup.cjs';
@@ -0,0 +1,3 @@
1
+ export { DepsService_alias_1 as DepsService } from '../_tsup-dts-rollup.js';
2
+ export { EnvService_alias_1 as EnvService } from '../_tsup-dts-rollup.js';
3
+ export { FileService_alias_3 as FileService } from '../_tsup-dts-rollup.js';
@@ -0,0 +1,2 @@
1
+ export { EnvService, FileService } from '../chunk-DYQ225MJ.js';
2
+ export { DepsService } from '../chunk-5UBGPRKT.js';
@@ -1,6 +1,3 @@
1
- import { createLogger } from '@mastra/core/logger';
2
- import { LibSQLStore } from '@mastra/core/storage/libsql';
3
- import { OTLPStorageExporter } from '@mastra/core/telemetry';
4
1
  import {
5
2
  NodeSDK,
6
3
  getNodeAutoInstrumentations,
@@ -12,6 +9,7 @@ import {
12
9
  AlwaysOffSampler,
13
10
  OTLPHttpExporter,
14
11
  OTLPGrpcExporter,
12
+ CompositeExporter,
15
13
  } from '@mastra/core/telemetry/otel-vendor';
16
14
  import { telemetry } from './telemetry-config.mjs';
17
15
 
@@ -39,47 +37,45 @@ function getSampler(config) {
39
37
  }
40
38
  }
41
39
 
42
- async function getExporter(config) {
40
+ async function getExporters(config) {
41
+ const exporters = [];
42
+
43
+ // Add local exporter by default
44
+ if (!config.disableLocalExport) {
45
+ exporters.push(new OTLPHttpExporter({
46
+ url: `http://localhost:${process.env.PORT ?? 4111}/api/telemetry`,
47
+ }));
48
+ }
49
+
43
50
  if (config.export?.type === 'otlp') {
44
- if(config.export?.protocol === "grpc") {
45
- return new OTLPGrpcExporter({
51
+ if (config.export?.protocol === 'grpc') {
52
+ exporters.push(new OTLPGrpcExporter({
53
+ url: config.export.endpoint,
54
+ headers: config.export.headers,
55
+ }));
56
+ } else {
57
+ exporters.push(new OTLPHttpExporter({
46
58
  url: config.export.endpoint,
47
59
  headers: config.export.headers,
48
- })
60
+ }));
49
61
  }
50
- return new OTLPHttpExporter({
51
- url: config.export.endpoint,
52
- headers: config.export.headers,
53
- });
54
62
  } else if (config.export?.type === 'custom') {
55
- return config.export.exporter;
56
- } else {
57
- const storage = new LibSQLStore({
58
- config: {
59
- url: 'file:.mastra/mastra.db',
60
- },
61
- });
62
- await storage.init();
63
-
64
- return new OTLPStorageExporter({
65
- logger: createLogger({
66
- name: 'telemetry',
67
- level: 'silent',
68
- }),
69
- storage,
70
- });
63
+ exporters.push(config.export.exporter);
71
64
  }
65
+
66
+ return exporters
72
67
  }
73
68
 
74
69
  const sampler = getSampler(telemetry);
75
- const exporter = await getExporter(telemetry);
70
+ const exporters = await getExporters(telemetry);
71
+ const compositeExporter = new CompositeExporter(exporters);
76
72
 
77
73
  const sdk = new NodeSDK({
78
74
  resource: new Resource({
79
75
  [ATTR_SERVICE_NAME]: telemetry.serviceName || 'default-service',
80
76
  }),
81
77
  sampler,
82
- traceExporter: exporter,
78
+ traceExporter: compositeExporter,
83
79
  instrumentations: [getNodeAutoInstrumentations()],
84
80
  });
85
81
 
@@ -91,4 +87,3 @@ process.on('SIGTERM', () => {
91
87
  // do nothing
92
88
  });
93
89
  });
94
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer",
3
- "version": "0.2.5",
3
+ "version": "0.2.6-alpha.10",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -29,6 +29,16 @@
29
29
  "default": "./dist/server/index.cjs"
30
30
  }
31
31
  },
32
+ "./services": {
33
+ "import": {
34
+ "types": "./dist/services/index.d.ts",
35
+ "default": "./dist/services/index.js"
36
+ },
37
+ "require": {
38
+ "types": "./dist/services/index.d.cts",
39
+ "default": "./dist/services/index.cjs"
40
+ }
41
+ },
32
42
  "./build": {
33
43
  "import": {
34
44
  "types": "./dist/build/index.d.ts",
@@ -75,7 +85,7 @@
75
85
  "author": "",
76
86
  "license": "ISC",
77
87
  "dependencies": {
78
- "@babel/core": "^7.26.9",
88
+ "@babel/core": "^7.26.10",
79
89
  "@babel/helper-module-imports": "^7.25.9",
80
90
  "@neon-rs/load": "^0.1.82",
81
91
  "@rollup/plugin-alias": "^5.1.1",
@@ -95,7 +105,8 @@
95
105
  "rollup-plugin-node-externals": "^8.0.0",
96
106
  "typescript-paths": "^1.5.1",
97
107
  "zod": "^3.24.2",
98
- "@mastra/core": "^0.7.0"
108
+ "@mastra/core": "^0.8.0-alpha.8",
109
+ "@mastra/server": "^0.0.1-alpha.6"
99
110
  },
100
111
  "devDependencies": {
101
112
  "@hono/node-server": "^1.13.8",
@@ -118,7 +129,7 @@
118
129
  "@internal/lint": "0.0.1"
119
130
  },
120
131
  "scripts": {
121
- "build": "tsup src/index.ts src/build/index.ts src/server/index.ts src/build/bundler.ts src/build/analyze.ts src/bundler/index.ts src/validator/loader.ts src/validator/custom-resolver.ts --format esm,cjs --clean --experimental-dts --treeshake=smallest --splitting --publicDir",
132
+ "build": "tsup src/index.ts src/build/index.ts src/server/index.ts src/build/bundler.ts src/build/analyze.ts src/bundler/index.ts src/services/index.ts src/validator/loader.ts src/validator/custom-resolver.ts --format esm,cjs --clean --experimental-dts --treeshake=smallest --splitting --publicDir",
122
133
  "build:watch": "pnpm build --watch",
123
134
  "pull:openapispec": "node src/server/openapi.script.js",
124
135
  "test": "vitest run",
@@ -1,286 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkNWERLYTR_cjs = require('./chunk-NWERLYTR.cjs');
4
- var chunkOT6UKL2S_cjs = require('./chunk-OT6UKL2S.cjs');
5
- var chunk54KOF3NB_cjs = require('./chunk-54KOF3NB.cjs');
6
- var alias = require('@rollup/plugin-alias');
7
- var commonjs = require('@rollup/plugin-commonjs');
8
- var json = require('@rollup/plugin-json');
9
- var pluginNodeResolve = require('@rollup/plugin-node-resolve');
10
- var module$1 = require('module');
11
- var path = require('path');
12
- var rollup = require('rollup');
13
- var esbuild = require('rollup-plugin-esbuild');
14
- var url = require('url');
15
- var fs2 = require('fs');
16
- var fsExtra = require('fs-extra/esm');
17
-
18
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
19
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
20
-
21
- function _interopNamespace(e) {
22
- if (e && e.__esModule) return e;
23
- var n = Object.create(null);
24
- if (e) {
25
- Object.keys(e).forEach(function (k) {
26
- if (k !== 'default') {
27
- var d = Object.getOwnPropertyDescriptor(e, k);
28
- Object.defineProperty(n, k, d.get ? d : {
29
- enumerable: true,
30
- get: function () { return e[k]; }
31
- });
32
- }
33
- });
34
- }
35
- n.default = e;
36
- return Object.freeze(n);
37
- }
38
-
39
- var alias__default = /*#__PURE__*/_interopDefault(alias);
40
- var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
41
- var json__default = /*#__PURE__*/_interopDefault(json);
42
- var path__default = /*#__PURE__*/_interopDefault(path);
43
- var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
44
- var fs2__namespace = /*#__PURE__*/_interopNamespace(fs2);
45
- var fsExtra__default = /*#__PURE__*/_interopDefault(fsExtra);
46
-
47
- var EnvService = class {
48
- };
49
- var FileEnvService = class extends EnvService {
50
- filePath;
51
- constructor(filePath) {
52
- super();
53
- this.filePath = filePath;
54
- }
55
- readFile(filePath) {
56
- return new Promise((resolve, reject) => {
57
- fs2__namespace.readFile(filePath, "utf8", (err, data) => {
58
- if (err) reject(err);
59
- else resolve(data);
60
- });
61
- });
62
- }
63
- writeFile({ filePath, data }) {
64
- return new Promise((resolve, reject) => {
65
- fs2__namespace.writeFile(filePath, data, "utf8", (err) => {
66
- if (err) reject(err);
67
- else resolve();
68
- });
69
- });
70
- }
71
- async updateEnvData({
72
- key,
73
- value,
74
- filePath = this.filePath,
75
- data
76
- }) {
77
- const regex = new RegExp(`^${key}=.*$`, "m");
78
- if (data.match(regex)) {
79
- data = data.replace(regex, `${key}=${value}`);
80
- } else {
81
- data += `
82
- ${key}=${value}`;
83
- }
84
- await this.writeFile({ filePath, data });
85
- console.log(`${key} set to ${value} in ENV file.`);
86
- return data;
87
- }
88
- async getEnvValue(key) {
89
- try {
90
- const data = await this.readFile(this.filePath);
91
- const regex = new RegExp(`^${key}=(.*)$`, "m");
92
- const match = data.match(regex);
93
- return match?.[1] || null;
94
- } catch (err) {
95
- console.error(`Error reading ENV value: ${err}`);
96
- return null;
97
- }
98
- }
99
- async setEnvValue(key, value) {
100
- try {
101
- const data = await this.readFile(this.filePath);
102
- await this.updateEnvData({ key, value, data });
103
- } catch (err) {
104
- console.error(`Error writing ENV value: ${err}`);
105
- }
106
- }
107
- };
108
-
109
- // src/build/fs.ts
110
- var FileService = class {
111
- /**
112
- *
113
- * @param inputFile the file in the starter files directory to copy
114
- * @param outputFilePath the destination path
115
- * @param replaceIfExists flag to replace if it exists
116
- * @returns
117
- */
118
- async copyStarterFile(inputFile, outputFilePath, replaceIfExists) {
119
- const __filename = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-7GYBZLVN.cjs', document.baseURI).href)));
120
- const __dirname = path__default.default.dirname(__filename);
121
- const filePath = path__default.default.resolve(__dirname, "..", "starter-files", inputFile);
122
- const fileString = fs2__namespace.default.readFileSync(filePath, "utf8");
123
- if (fs2__namespace.default.existsSync(outputFilePath) && !replaceIfExists) {
124
- console.log(`${outputFilePath} already exists`);
125
- return false;
126
- }
127
- await fsExtra__default.default.outputFile(outputFilePath, fileString);
128
- return true;
129
- }
130
- async setupEnvFile({ dbUrl }) {
131
- const envPath = path__default.default.join(process.cwd(), ".env.development");
132
- await fsExtra__default.default.ensureFile(envPath);
133
- const fileEnvService = new FileEnvService(envPath);
134
- await fileEnvService.setEnvValue("DB_URL", dbUrl);
135
- }
136
- getFirstExistingFile(files) {
137
- for (const f of files) {
138
- if (fs2__namespace.default.existsSync(f)) {
139
- return f;
140
- }
141
- }
142
- throw new Error("Missing required file, checked the following paths: " + files.join(", "));
143
- }
144
- replaceValuesInFile({
145
- filePath,
146
- replacements
147
- }) {
148
- let fileContent = fs2__namespace.default.readFileSync(filePath, "utf8");
149
- replacements.forEach(({ search, replace }) => {
150
- fileContent = fileContent.replaceAll(search, replace);
151
- });
152
- fs2__namespace.default.writeFileSync(filePath, fileContent);
153
- }
154
- };
155
-
156
- // src/build/bundle.ts
157
- function getOptions(inputOptions, platform, root) {
158
- const fileService = new FileService();
159
- const entry = fileService.getFirstExistingFile([
160
- path.join(root, "src/mastra/index.ts"),
161
- path.join(root, "src/mastra/index.js")
162
- ]);
163
- const nodeBuiltins = platform === "node" ? module$1.builtinModules : [];
164
- let nodeResolvePlugin = platform === "node" ? pluginNodeResolve.nodeResolve({
165
- preferBuiltins: true,
166
- exportConditions: ["node", "import", "require"],
167
- mainFields: ["module", "main"]
168
- }) : pluginNodeResolve.nodeResolve({
169
- preferBuiltins: false,
170
- exportConditions: ["browser", "import", "require"],
171
- mainFields: ["module", "main"],
172
- browser: true
173
- });
174
- return {
175
- logLevel: "silent",
176
- ...inputOptions,
177
- treeshake: "smallest",
178
- preserveSymlinks: true,
179
- external: [
180
- ...nodeBuiltins,
181
- ...nodeBuiltins.map((builtin) => "node:" + builtin),
182
- ...inputOptions.external ?? []
183
- ],
184
- plugins: [
185
- ...inputOptions.plugins ?? [],
186
- alias__default.default({
187
- entries: [
188
- {
189
- find: /^\#server$/,
190
- replacement: url.fileURLToPath(undefined("@mastra/deployer/server")).replaceAll("\\", "/")
191
- },
192
- { find: /^\#mastra$/, replacement: entry.replaceAll("\\", "/") },
193
- {
194
- find: /^hono\//,
195
- replacement: "hono/",
196
- customResolver: (id, importer) => {
197
- if (!importer?.startsWith("\0virtual")) {
198
- return null;
199
- }
200
- const path2 = undefined(id);
201
- return url.fileURLToPath(path2);
202
- }
203
- }
204
- ]
205
- }),
206
- commonjs__default.default({
207
- strictRequires: "strict",
208
- transformMixedEsModules: true
209
- // dynamicRequireTargets: ['node_modules/**/@libsql+win32-*/*'],
210
- }),
211
- // for debugging
212
- // {
213
- // name: 'logger',
214
- // // @ts-ignore
215
- // resolveId(id, ...args) {
216
- // console.log({ id, args });
217
- // },
218
- // },
219
- nodeResolvePlugin,
220
- json__default.default(),
221
- esbuild__default.default({
222
- include: /\.tsx?$/,
223
- target: "node20",
224
- platform,
225
- minify: false,
226
- define: {
227
- "process.env.NODE_ENV": JSON.stringify("production")
228
- }
229
- }),
230
- chunk54KOF3NB_cjs.removeDeployer(entry),
231
- esbuild__default.default({
232
- include: entry,
233
- target: "node20",
234
- platform,
235
- minify: false
236
- })
237
- ].filter(Boolean)
238
- };
239
- }
240
- async function getBundler(inputOptions, args = {}) {
241
- const { platform = "node", dir = process.cwd() } = args;
242
- const bundle = await rollup.rollup(getOptions(inputOptions, platform, dir));
243
- return bundle;
244
- }
245
- async function getWatcher(inputOptions, args = {}) {
246
- const { platform = "node", dir = process.cwd() } = args;
247
- const watcher = rollup.watch(getOptions(inputOptions, platform, dir));
248
- return watcher;
249
- }
250
- async function getInputOptions2(entryFile, platform) {
251
- const inputOptions = await chunkOT6UKL2S_cjs.getInputOptions(
252
- entryFile,
253
- {
254
- dependencies: /* @__PURE__ */ new Map(),
255
- externalDependencies: /* @__PURE__ */ new Set(),
256
- invalidChunks: /* @__PURE__ */ new Set()
257
- },
258
- platform
259
- );
260
- if (Array.isArray(inputOptions.plugins)) {
261
- inputOptions.plugins = inputOptions.plugins.filter(
262
- // @ts-ignore
263
- (plugin) => !plugin || !plugin?.name || plugin.name !== "node-resolve"
264
- );
265
- inputOptions.plugins.push(chunkNWERLYTR_cjs.aliasHono());
266
- }
267
- return inputOptions;
268
- }
269
- async function createWatcher(inputOptions, outputOptions) {
270
- const watcher = await rollup.watch({
271
- ...inputOptions,
272
- output: {
273
- ...outputOptions,
274
- format: "esm",
275
- entryFileNames: "[name].mjs",
276
- chunkFileNames: "[name].mjs"
277
- }
278
- });
279
- return watcher;
280
- }
281
-
282
- exports.FileService = FileService;
283
- exports.createWatcher = createWatcher;
284
- exports.getBundler = getBundler;
285
- exports.getInputOptions = getInputOptions2;
286
- exports.getWatcher = getWatcher;