@mastra/deployer 0.10.13 → 0.10.15-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +844 -0
  2. package/dist/_tsup-dts-rollup.d.ts +844 -0
  3. package/dist/build/analyze.cjs +10 -0
  4. package/dist/build/analyze.d.cts +1 -0
  5. package/dist/build/analyze.d.ts +1 -0
  6. package/dist/build/analyze.js +1 -0
  7. package/dist/build/bundler.cjs +14 -0
  8. package/dist/build/bundler.d.cts +2 -0
  9. package/dist/build/bundler.d.ts +2 -0
  10. package/dist/build/bundler.js +1 -0
  11. package/dist/build/index.cjs +50 -0
  12. package/dist/build/index.d.cts +10 -0
  13. package/dist/build/index.d.ts +10 -0
  14. package/dist/build/index.js +5 -0
  15. package/dist/bundler/index.cjs +10 -0
  16. package/dist/bundler/index.d.cts +1 -0
  17. package/dist/bundler/index.d.ts +1 -0
  18. package/dist/bundler/index.js +1 -0
  19. package/dist/chunk-54KOF3NB.cjs +137 -0
  20. package/dist/chunk-6QMONK4A.cjs +2 -0
  21. package/dist/chunk-C4JT7CIH.js +1 -0
  22. package/dist/chunk-D2DCFCLH.cjs +157 -0
  23. package/dist/chunk-D6736SJL.js +209 -0
  24. package/dist/chunk-ENT5RDOI.js +99 -0
  25. package/dist/chunk-FK2WUSEN.cjs +238 -0
  26. package/dist/chunk-GPD54HBC.js +380 -0
  27. package/dist/chunk-HJGC75ZR.js +490 -0
  28. package/dist/chunk-KCP5ITLV.cjs +412 -0
  29. package/dist/chunk-M2VZQFTW.cjs +125 -0
  30. package/dist/chunk-TIC2KT3M.js +146 -0
  31. package/dist/chunk-UYQZMNZL.js +572 -0
  32. package/dist/chunk-XKH6F4NE.cjs +604 -0
  33. package/dist/chunk-YFMAWUII.cjs +502 -0
  34. package/dist/chunk-Z544XXXK.js +111 -0
  35. package/dist/index.cjs +194 -0
  36. package/dist/index.d.cts +8 -0
  37. package/dist/index.d.ts +8 -0
  38. package/dist/index.js +153 -0
  39. package/dist/server/index.cjs +8446 -0
  40. package/dist/server/index.d.cts +2 -0
  41. package/dist/server/index.d.ts +2 -0
  42. package/dist/server/index.js +8438 -0
  43. package/dist/services/index.cjs +18 -0
  44. package/dist/services/index.d.cts +3 -0
  45. package/dist/services/index.d.ts +3 -0
  46. package/dist/services/index.js +1 -0
  47. package/dist/templates/instrumentation-template.js +137 -0
  48. package/dist/validator/custom-resolver.cjs +52 -0
  49. package/dist/validator/custom-resolver.d.cts +1 -0
  50. package/dist/validator/custom-resolver.d.ts +1 -0
  51. package/dist/validator/custom-resolver.js +50 -0
  52. package/dist/validator/loader.cjs +7 -0
  53. package/dist/validator/loader.d.cts +1 -0
  54. package/dist/validator/loader.d.ts +1 -0
  55. package/dist/validator/loader.js +4 -0
  56. package/package.json +5 -5
package/dist/index.cjs ADDED
@@ -0,0 +1,194 @@
1
+ 'use strict';
2
+
3
+ var chunkYFMAWUII_cjs = require('./chunk-YFMAWUII.cjs');
4
+ var chunkXKH6F4NE_cjs = require('./chunk-XKH6F4NE.cjs');
5
+ var chunkKCP5ITLV_cjs = require('./chunk-KCP5ITLV.cjs');
6
+ var babel = require('@babel/core');
7
+ var rollup = require('rollup');
8
+ var esbuild = require('rollup-plugin-esbuild');
9
+ var commonjs = require('@rollup/plugin-commonjs');
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 babel__namespace = /*#__PURE__*/_interopNamespace(babel);
32
+ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
33
+ var commonjs__default = /*#__PURE__*/_interopDefault(commonjs);
34
+
35
+ // src/deploy/base.ts
36
+ var Deployer = class extends chunkYFMAWUII_cjs.Bundler {
37
+ deps = new chunkKCP5ITLV_cjs.DepsService();
38
+ constructor(args) {
39
+ super(args.name, "DEPLOYER");
40
+ this.deps.__setLogger(this.logger);
41
+ }
42
+ getEnvFiles() {
43
+ const possibleFiles = [".env.production", ".env.local", ".env"];
44
+ try {
45
+ const fileService = new chunkKCP5ITLV_cjs.FileService();
46
+ const envFile = fileService.getFirstExistingFile(possibleFiles);
47
+ return Promise.resolve([envFile]);
48
+ } catch {
49
+ }
50
+ return Promise.resolve([]);
51
+ }
52
+ };
53
+ function removeAllExceptDeployer() {
54
+ const t = babel__namespace.default.types;
55
+ return {
56
+ name: "remove-all-except-deployer",
57
+ visitor: {
58
+ ExportNamedDeclaration: {
59
+ // remove all exports
60
+ exit(path) {
61
+ path.remove();
62
+ }
63
+ },
64
+ NewExpression(path) {
65
+ const varDeclaratorPath = path.findParent((path2) => t.isVariableDeclarator(path2.node));
66
+ if (!varDeclaratorPath) {
67
+ return;
68
+ }
69
+ const parentNode = path.parentPath.node;
70
+ if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
71
+ return;
72
+ }
73
+ const deployer = path.node.arguments[0]?.properties?.find(
74
+ // @ts-ignore
75
+ (prop) => prop.key.name === "deployer"
76
+ );
77
+ const programPath = path.scope.getProgramParent().path;
78
+ if (!deployer || !programPath) {
79
+ return;
80
+ }
81
+ const exportDeclaration = t.exportNamedDeclaration(
82
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier("deployer"), deployer.value)]),
83
+ []
84
+ );
85
+ programPath.node.body.push(exportDeclaration);
86
+ }
87
+ }
88
+ };
89
+ }
90
+ function getDeployerBundler(entryFile, result) {
91
+ return rollup.rollup({
92
+ logLevel: "silent",
93
+ input: {
94
+ deployer: entryFile
95
+ },
96
+ treeshake: "smallest",
97
+ plugins: [
98
+ // transpile typescript to something we understand
99
+ esbuild__default.default({
100
+ target: "node20",
101
+ platform: "node",
102
+ minify: false
103
+ }),
104
+ commonjs__default.default({
105
+ extensions: [".js", ".ts"],
106
+ strictRequires: "strict",
107
+ transformMixedEsModules: true,
108
+ ignoreTryCatch: false
109
+ }),
110
+ {
111
+ name: "get-deployer",
112
+ transform(code, id) {
113
+ if (id !== entryFile) {
114
+ return;
115
+ }
116
+ result.isDeployerRemoved = true;
117
+ return new Promise((resolve, reject) => {
118
+ babel__namespace.transform(
119
+ code,
120
+ {
121
+ babelrc: false,
122
+ configFile: false,
123
+ filename: id,
124
+ plugins: [removeAllExceptDeployer]
125
+ },
126
+ (err, result2) => {
127
+ if (err) {
128
+ return reject(err);
129
+ }
130
+ resolve({
131
+ code: result2.code,
132
+ map: result2.map
133
+ });
134
+ }
135
+ );
136
+ });
137
+ }
138
+ },
139
+ // let esbuild remove all unused imports
140
+ esbuild__default.default({
141
+ target: "node20",
142
+ platform: "node",
143
+ minify: false
144
+ }),
145
+ {
146
+ name: "cleanup-nodes",
147
+ transform(code, id) {
148
+ if (id !== entryFile) {
149
+ return;
150
+ }
151
+ return chunkXKH6F4NE_cjs.recursiveRemoveNonReferencedNodes(code);
152
+ }
153
+ },
154
+ // let esbuild remove all unused imports
155
+ esbuild__default.default({
156
+ target: "node20",
157
+ platform: "node",
158
+ minify: false
159
+ })
160
+ ]
161
+ });
162
+ }
163
+ async function getDeployer(entryFile, outputDir) {
164
+ const result = { isDeployerRemoved: false };
165
+ const bundle = await getDeployerBundler(entryFile, result);
166
+ await bundle.write({
167
+ dir: outputDir,
168
+ format: "es",
169
+ entryFileNames: "[name].mjs"
170
+ });
171
+ if (!result.isDeployerRemoved) {
172
+ return;
173
+ }
174
+ return (await import(`file:${outputDir}/deployer.mjs`)).deployer;
175
+ }
176
+
177
+ Object.defineProperty(exports, "Deps", {
178
+ enumerable: true,
179
+ get: function () { return chunkKCP5ITLV_cjs.Deps; }
180
+ });
181
+ Object.defineProperty(exports, "FileService", {
182
+ enumerable: true,
183
+ get: function () { return chunkKCP5ITLV_cjs.FileService; }
184
+ });
185
+ Object.defineProperty(exports, "createChildProcessLogger", {
186
+ enumerable: true,
187
+ get: function () { return chunkKCP5ITLV_cjs.createChildProcessLogger; }
188
+ });
189
+ Object.defineProperty(exports, "createPinoStream", {
190
+ enumerable: true,
191
+ get: function () { return chunkKCP5ITLV_cjs.createPinoStream; }
192
+ });
193
+ exports.Deployer = Deployer;
194
+ exports.getDeployer = getDeployer;
@@ -0,0 +1,8 @@
1
+ export { Deps } from './_tsup-dts-rollup.cjs';
2
+ export { FileService } from './_tsup-dts-rollup.cjs';
3
+ export { getDeployer } from './_tsup-dts-rollup.cjs';
4
+ export { Deployer } from './_tsup-dts-rollup.cjs';
5
+ export { createChildProcessLogger } from './_tsup-dts-rollup.cjs';
6
+ export { createPinoStream } from './_tsup-dts-rollup.cjs';
7
+ export { ApiError } from './_tsup-dts-rollup.cjs';
8
+ export { ServerBundleOptions } from './_tsup-dts-rollup.cjs';
@@ -0,0 +1,8 @@
1
+ export { Deps } from './_tsup-dts-rollup.js';
2
+ export { FileService } from './_tsup-dts-rollup.js';
3
+ export { getDeployer } from './_tsup-dts-rollup.js';
4
+ export { Deployer } from './_tsup-dts-rollup.js';
5
+ export { createChildProcessLogger } from './_tsup-dts-rollup.js';
6
+ export { createPinoStream } from './_tsup-dts-rollup.js';
7
+ export { ApiError } from './_tsup-dts-rollup.js';
8
+ export { ServerBundleOptions } from './_tsup-dts-rollup.js';
package/dist/index.js ADDED
@@ -0,0 +1,153 @@
1
+ import { Bundler } from './chunk-HJGC75ZR.js';
2
+ import { recursiveRemoveNonReferencedNodes } from './chunk-UYQZMNZL.js';
3
+ import { DepsService, FileService } from './chunk-GPD54HBC.js';
4
+ export { Deps, FileService, createChildProcessLogger, createPinoStream } from './chunk-GPD54HBC.js';
5
+ import * as babel from '@babel/core';
6
+ import babel__default from '@babel/core';
7
+ import { rollup } from 'rollup';
8
+ import esbuild from 'rollup-plugin-esbuild';
9
+ import commonjs from '@rollup/plugin-commonjs';
10
+
11
+ // src/deploy/base.ts
12
+ var Deployer = class extends Bundler {
13
+ deps = new DepsService();
14
+ constructor(args) {
15
+ super(args.name, "DEPLOYER");
16
+ this.deps.__setLogger(this.logger);
17
+ }
18
+ getEnvFiles() {
19
+ const possibleFiles = [".env.production", ".env.local", ".env"];
20
+ try {
21
+ const fileService = new FileService();
22
+ const envFile = fileService.getFirstExistingFile(possibleFiles);
23
+ return Promise.resolve([envFile]);
24
+ } catch {
25
+ }
26
+ return Promise.resolve([]);
27
+ }
28
+ };
29
+ function removeAllExceptDeployer() {
30
+ const t = babel__default.types;
31
+ return {
32
+ name: "remove-all-except-deployer",
33
+ visitor: {
34
+ ExportNamedDeclaration: {
35
+ // remove all exports
36
+ exit(path) {
37
+ path.remove();
38
+ }
39
+ },
40
+ NewExpression(path) {
41
+ const varDeclaratorPath = path.findParent((path2) => t.isVariableDeclarator(path2.node));
42
+ if (!varDeclaratorPath) {
43
+ return;
44
+ }
45
+ const parentNode = path.parentPath.node;
46
+ if (!t.isVariableDeclarator(parentNode) || !t.isIdentifier(parentNode.id) || parentNode.id.name !== "mastra") {
47
+ return;
48
+ }
49
+ const deployer = path.node.arguments[0]?.properties?.find(
50
+ // @ts-ignore
51
+ (prop) => prop.key.name === "deployer"
52
+ );
53
+ const programPath = path.scope.getProgramParent().path;
54
+ if (!deployer || !programPath) {
55
+ return;
56
+ }
57
+ const exportDeclaration = t.exportNamedDeclaration(
58
+ t.variableDeclaration("const", [t.variableDeclarator(t.identifier("deployer"), deployer.value)]),
59
+ []
60
+ );
61
+ programPath.node.body.push(exportDeclaration);
62
+ }
63
+ }
64
+ };
65
+ }
66
+ function getDeployerBundler(entryFile, result) {
67
+ return rollup({
68
+ logLevel: "silent",
69
+ input: {
70
+ deployer: entryFile
71
+ },
72
+ treeshake: "smallest",
73
+ plugins: [
74
+ // transpile typescript to something we understand
75
+ esbuild({
76
+ target: "node20",
77
+ platform: "node",
78
+ minify: false
79
+ }),
80
+ commonjs({
81
+ extensions: [".js", ".ts"],
82
+ strictRequires: "strict",
83
+ transformMixedEsModules: true,
84
+ ignoreTryCatch: false
85
+ }),
86
+ {
87
+ name: "get-deployer",
88
+ transform(code, id) {
89
+ if (id !== entryFile) {
90
+ return;
91
+ }
92
+ result.isDeployerRemoved = true;
93
+ return new Promise((resolve, reject) => {
94
+ babel.transform(
95
+ code,
96
+ {
97
+ babelrc: false,
98
+ configFile: false,
99
+ filename: id,
100
+ plugins: [removeAllExceptDeployer]
101
+ },
102
+ (err, result2) => {
103
+ if (err) {
104
+ return reject(err);
105
+ }
106
+ resolve({
107
+ code: result2.code,
108
+ map: result2.map
109
+ });
110
+ }
111
+ );
112
+ });
113
+ }
114
+ },
115
+ // let esbuild remove all unused imports
116
+ esbuild({
117
+ target: "node20",
118
+ platform: "node",
119
+ minify: false
120
+ }),
121
+ {
122
+ name: "cleanup-nodes",
123
+ transform(code, id) {
124
+ if (id !== entryFile) {
125
+ return;
126
+ }
127
+ return recursiveRemoveNonReferencedNodes(code);
128
+ }
129
+ },
130
+ // let esbuild remove all unused imports
131
+ esbuild({
132
+ target: "node20",
133
+ platform: "node",
134
+ minify: false
135
+ })
136
+ ]
137
+ });
138
+ }
139
+ async function getDeployer(entryFile, outputDir) {
140
+ const result = { isDeployerRemoved: false };
141
+ const bundle = await getDeployerBundler(entryFile, result);
142
+ await bundle.write({
143
+ dir: outputDir,
144
+ format: "es",
145
+ entryFileNames: "[name].mjs"
146
+ });
147
+ if (!result.isDeployerRemoved) {
148
+ return;
149
+ }
150
+ return (await import(`file:${outputDir}/deployer.mjs`)).deployer;
151
+ }
152
+
153
+ export { Deployer, getDeployer };