@mastra/deployer-netlify 0.0.0-storage-20250225005900 → 0.0.0-stream-vnext-usage-20250908171242

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/LICENSE.md ADDED
@@ -0,0 +1,15 @@
1
+ # Apache License 2.0
2
+
3
+ Copyright (c) 2025 Kepler Software, Inc.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
package/README.md CHANGED
@@ -26,6 +26,7 @@ import { NetlifyDeployer } from '@mastra/deployer-netlify';
26
26
  const deployer = new NetlifyDeployer({
27
27
  scope: 'your-team-id',
28
28
  projectName: 'your-project-name',
29
+ token: 'your-netlify-token',
29
30
  });
30
31
 
31
32
  const mastra = new Mastra({
@@ -38,8 +39,9 @@ const mastra = new Mastra({
38
39
 
39
40
  ### Constructor Options
40
41
 
41
- - `scope` (required): Your Netlify team ID
42
+ - `scope` (required): Your Netlify team slug or ID
42
43
  - `projectName`: Name of your Netlify site (will be created if it doesn't exist)
44
+ - `token`: Your Netlify authentication token
43
45
 
44
46
  ## Project Structure
45
47
 
package/dist/index.cjs ADDED
@@ -0,0 +1,121 @@
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+ var process = require('process');
5
+ var deployer = require('@mastra/deployer');
6
+ var services = require('@mastra/deployer/services');
7
+ var esm = require('fs-extra/esm');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var process__default = /*#__PURE__*/_interopDefault(process);
12
+
13
+ // src/index.ts
14
+ var NetlifyDeployer = class extends deployer.Deployer {
15
+ constructor() {
16
+ super({ name: "NETLIFY" });
17
+ this.outputDir = path.join(".netlify", "v1", "functions", "api");
18
+ }
19
+ async installDependencies(outputDirectory, rootDir = process__default.default.cwd()) {
20
+ const deps = new services.DepsService(rootDir);
21
+ deps.__setLogger(this.logger);
22
+ await deps.install({
23
+ dir: path.join(outputDirectory, this.outputDir),
24
+ architecture: {
25
+ os: ["linux"],
26
+ cpu: ["x64"],
27
+ libc: ["gnu"]
28
+ }
29
+ });
30
+ }
31
+ async deploy() {
32
+ this.logger?.info("Deploying to Netlify failed. Please use the Netlify dashboard to deploy.");
33
+ }
34
+ async prepare(outputDirectory) {
35
+ await super.prepare(outputDirectory);
36
+ }
37
+ async bundle(entryFile, outputDirectory, toolsPaths) {
38
+ const result = await this._bundle(
39
+ this.getEntry(),
40
+ entryFile,
41
+ outputDirectory,
42
+ toolsPaths,
43
+ path.join(outputDirectory, this.outputDir)
44
+ );
45
+ await esm.writeJson(path.join(outputDirectory, ".netlify", "v1", "config.json"), {
46
+ redirects: [
47
+ {
48
+ force: true,
49
+ from: "/*",
50
+ to: "/.netlify/functions/api/:splat",
51
+ status: 200
52
+ }
53
+ ]
54
+ });
55
+ await esm.move(path.join(outputDirectory, ".netlify", "v1"), path.join(process__default.default.cwd(), ".netlify", "v1"), {
56
+ overwrite: true
57
+ });
58
+ return result;
59
+ }
60
+ getEntry() {
61
+ return `
62
+ import { handle } from 'hono/netlify'
63
+ import { mastra } from '#mastra';
64
+ import { createHonoServer, getToolExports } from '#server';
65
+ import { tools } from '#tools';
66
+ import { evaluate } from '@mastra/core/eval';
67
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
68
+ import { TABLE_EVALS } from '@mastra/core/storage';
69
+ import { checkEvalStorageFields } from '@mastra/core/utils';
70
+
71
+ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
72
+ evaluate({
73
+ agentName,
74
+ input,
75
+ metric,
76
+ output,
77
+ runId,
78
+ globalRunId: runId,
79
+ instructions,
80
+ });
81
+ });
82
+
83
+ registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
84
+ const storage = mastra.getStorage();
85
+ if (storage) {
86
+ // Check for required fields
87
+ const logger = mastra.getLogger();
88
+ const areFieldsValid = checkEvalStorageFields(traceObject, logger);
89
+ if (!areFieldsValid) return;
90
+
91
+ await storage.insert({
92
+ tableName: TABLE_EVALS,
93
+ record: {
94
+ input: traceObject.input,
95
+ output: traceObject.output,
96
+ result: JSON.stringify(traceObject.result || {}),
97
+ agent_name: traceObject.agentName,
98
+ metric_name: traceObject.metricName,
99
+ instructions: traceObject.instructions,
100
+ test_info: null,
101
+ global_run_id: traceObject.globalRunId,
102
+ run_id: traceObject.runId,
103
+ created_at: new Date().toISOString(),
104
+ },
105
+ });
106
+ }
107
+ });
108
+
109
+ const app = await createHonoServer(mastra, { tools: getToolExports(tools) });
110
+
111
+ export default handle(app)
112
+ `;
113
+ }
114
+ async lint(entryFile, outputDirectory, toolsPaths) {
115
+ await super.lint(entryFile, outputDirectory, toolsPaths);
116
+ }
117
+ };
118
+
119
+ exports.NetlifyDeployer = NetlifyDeployer;
120
+ //# sourceMappingURL=index.cjs.map
121
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["Deployer","join","process","DepsService","writeJson","move"],"mappings":";;;;;;;;;;;;;AAMO,IAAM,eAAA,GAAN,cAA8BA,iBAAA,CAAS;AAAA,EAC5C,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,EAAE,IAAA,EAAM,SAAA,EAAW,CAAA;AACzB,IAAA,IAAA,CAAK,SAAA,GAAYC,SAAA,CAAK,UAAA,EAAY,IAAA,EAAM,aAAa,KAAK,CAAA;AAAA,EAC5D;AAAA,EAEA,MAAgB,mBAAA,CAAoB,eAAA,EAAyB,OAAA,GAAUC,wBAAA,CAAQ,KAAI,EAAG;AACpF,IAAA,MAAM,IAAA,GAAO,IAAIC,oBAAA,CAAY,OAAO,CAAA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Y,IAAI,CAAA,EAAG;AAAA,MACzF,SAAA,EAAW;AAAA,KACZ,CAAA;AAED,IAAA,OAAO,MAAA;AAAA,EACT;AAAA,EAEQ,QAAA,GAAmB;AACzB,IAAA,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA,CAAA;AAAA,EAoDT;AAAA,EAEA,MAAM,IAAA,CAAK,SAAA,EAAmB,eAAA,EAAyB,UAAA,EAAkD;AACvG,IAAA,MAAM,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,eAAA,EAAiB,UAAU,CAAA;AAAA,EAGzD;AACF","file":"index.cjs","sourcesContent":["import { join } from 'path';\nimport process from 'process';\nimport { Deployer } from '@mastra/deployer';\nimport { DepsService } from '@mastra/deployer/services';\nimport { move, writeJson } from 'fs-extra/esm';\n\nexport class NetlifyDeployer extends Deployer {\n constructor() {\n super({ name: 'NETLIFY' });\n this.outputDir = join('.netlify', 'v1', 'functions', 'api');\n }\n\n protected async installDependencies(outputDirectory: string, rootDir = process.cwd()) {\n const deps = new DepsService(rootDir);\n deps.__setLogger(this.logger);\n\n await deps.install({\n dir: join(outputDirectory, this.outputDir),\n architecture: {\n os: ['linux'],\n cpu: ['x64'],\n libc: ['gnu'],\n },\n });\n }\n\n async deploy(): Promise<void> {\n this.logger?.info('Deploying to Netlify failed. Please use the Netlify dashboard to deploy.');\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n await super.prepare(outputDirectory);\n }\n\n async bundle(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n outputDirectory,\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n await writeJson(join(outputDirectory, '.netlify', 'v1', 'config.json'), {\n redirects: [\n {\n force: true,\n from: '/*',\n to: '/.netlify/functions/api/:splat',\n status: 200,\n },\n ],\n });\n\n await move(join(outputDirectory, '.netlify', 'v1'), join(process.cwd(), '.netlify', 'v1'), {\n overwrite: true,\n });\n\n return result;\n }\n\n private getEntry(): string {\n return `\n import { handle } from 'hono/netlify'\n import { mastra } from '#mastra';\n import { createHonoServer, getToolExports } from '#server';\n import { tools } from '#tools';\n import { evaluate } from '@mastra/core/eval';\n import { AvailableHooks, registerHook } from '@mastra/core/hooks';\n import { TABLE_EVALS } from '@mastra/core/storage';\n import { checkEvalStorageFields } from '@mastra/core/utils';\n\n registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {\n evaluate({\n agentName,\n input,\n metric,\n output,\n runId,\n globalRunId: runId,\n instructions,\n });\n });\n\n registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {\n const storage = mastra.getStorage();\n if (storage) {\n // Check for required fields\n const logger = mastra.getLogger();\n const areFieldsValid = checkEvalStorageFields(traceObject, logger);\n if (!areFieldsValid) return;\n\n await storage.insert({\n tableName: TABLE_EVALS,\n record: {\n input: traceObject.input,\n output: traceObject.output,\n result: JSON.stringify(traceObject.result || {}),\n agent_name: traceObject.agentName,\n metric_name: traceObject.metricName,\n instructions: traceObject.instructions,\n test_info: null,\n global_run_id: traceObject.globalRunId,\n run_id: traceObject.runId,\n created_at: new Date().toISOString(),\n },\n });\n }\n });\n\n const app = await createHonoServer(mastra, { tools: getToolExports(tools) });\n\n export default handle(app)\n`;\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n\n // Lint for netlify support\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1 +1,11 @@
1
- export { NetlifyDeployer } from './_tsup-dts-rollup.js';
1
+ import { Deployer } from '@mastra/deployer';
2
+ export declare class NetlifyDeployer extends Deployer {
3
+ constructor();
4
+ protected installDependencies(outputDirectory: string, rootDir?: string): Promise<void>;
5
+ deploy(): Promise<void>;
6
+ prepare(outputDirectory: string): Promise<void>;
7
+ bundle(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void>;
8
+ private getEntry;
9
+ lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void>;
10
+ }
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,qBAAa,eAAgB,SAAQ,QAAQ;;cAM3B,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,SAAgB;IAc9E,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,OAAO,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B1G,OAAO,CAAC,QAAQ;IAuDV,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAKzG"}
package/dist/index.js CHANGED
@@ -1,138 +1,115 @@
1
- import { Deployer } from '@mastra/deployer';
2
- import { execa } from 'execa';
3
- import { existsSync, mkdirSync, writeFileSync } from 'fs';
4
1
  import { join } from 'path';
5
-
6
- // src/index.ts
7
-
8
- // src/helpers.ts
9
- async function createNetlifySite({ token, name, scope }) {
10
- const response = await fetch("https://api.netlify.com/api/v1/sites", {
11
- method: "POST",
12
- headers: {
13
- Authorization: `Bearer ${token}`,
14
- "Content-Type": "application/json"
15
- },
16
- body: JSON.stringify({
17
- name,
18
- account_slug: scope,
19
- // Optional - if not provided, creates in user's default account
20
- force_ssl: true
21
- // Enable HTTPS
22
- })
23
- });
24
- const data = await response.json();
25
- if (!response.ok) {
26
- console.error(JSON.stringify(data));
27
- throw new Error(`Failed to create site: ${data.message || "Unknown error"}`);
28
- }
29
- return {
30
- id: data.id,
31
- name: data.name,
32
- url: data.ssl_url || data.url,
33
- adminUrl: data.admin_url
34
- };
35
- }
36
- async function findNetlifySite({ token, name, scope }) {
37
- const response = await fetch(`https://api.netlify.com/api/v1/${scope}/sites?filter=all&name=${name}`, {
38
- headers: {
39
- Authorization: `Bearer ${token}`,
40
- "Content-Type": "application/json"
41
- }
42
- });
43
- const data = await response.json();
44
- if (!response.ok || !Array.isArray(data)) {
45
- throw new Error(`Failed to search sites: ${data.message || "Unknown error"}`);
46
- }
47
- return data.find((site) => site.name === name);
48
- }
49
- async function getOrCreateSite({ token, name, scope }) {
50
- let existingSite;
51
- try {
52
- existingSite = await findNetlifySite({ token, name, scope });
53
- } catch (e) {
54
- }
55
- if (existingSite) {
56
- return existingSite;
57
- }
58
- return createNetlifySite({ token, name, scope });
59
- }
2
+ import process from 'process';
3
+ import { Deployer } from '@mastra/deployer';
4
+ import { DepsService } from '@mastra/deployer/services';
5
+ import { writeJson, move } from 'fs-extra/esm';
60
6
 
61
7
  // src/index.ts
62
8
  var NetlifyDeployer = class extends Deployer {
63
- scope;
64
- projectName;
65
- token;
66
- constructor({ scope, projectName, token }) {
9
+ constructor() {
67
10
  super({ name: "NETLIFY" });
68
- this.scope = scope;
69
- this.projectName = projectName;
70
- this.token = token;
11
+ this.outputDir = join(".netlify", "v1", "functions", "api");
71
12
  }
72
- writeFiles({ dir }) {
73
- if (!existsSync(join(dir, "netlify/functions/api"))) {
74
- mkdirSync(join(dir, "netlify/functions/api"), { recursive: true });
75
- }
76
- writeFileSync(
77
- join(dir, "netlify.toml"),
78
- `[functions]
79
- node_bundler = "esbuild"
80
- directory = "netlify/functions"
81
-
82
- [[redirects]]
83
- force = true
84
- from = "/*"
85
- status = 200
86
- to = "/.netlify/functions/api/:splat"
87
- `
88
- );
89
- }
90
- async deploy(outputDirectory) {
91
- const site = await getOrCreateSite({ token: this.token, name: this.projectName || `mastra`, scope: this.scope });
92
- const p2 = execa(
93
- "npx",
94
- [
95
- "netlify-cli",
96
- "deploy",
97
- "--site",
98
- site.id,
99
- "--auth",
100
- this.token,
101
- "--dir",
102
- ".",
103
- "--functions",
104
- "./netlify/functions"
105
- ],
106
- {
107
- cwd: join(outputDirectory, this.outputDir)
13
+ async installDependencies(outputDirectory, rootDir = process.cwd()) {
14
+ const deps = new DepsService(rootDir);
15
+ deps.__setLogger(this.logger);
16
+ await deps.install({
17
+ dir: join(outputDirectory, this.outputDir),
18
+ architecture: {
19
+ os: ["linux"],
20
+ cpu: ["x64"],
21
+ libc: ["gnu"]
108
22
  }
109
- );
110
- p2.stdout.pipe(process.stdout);
111
- await p2;
23
+ });
24
+ }
25
+ async deploy() {
26
+ this.logger?.info("Deploying to Netlify failed. Please use the Netlify dashboard to deploy.");
112
27
  }
113
28
  async prepare(outputDirectory) {
114
29
  await super.prepare(outputDirectory);
115
- this.writeFiles({ dir: join(outputDirectory, this.outputDir) });
116
30
  }
117
- async bundle(entryFile, outputDirectory) {
118
- return this._bundle(
31
+ async bundle(entryFile, outputDirectory, toolsPaths) {
32
+ const result = await this._bundle(
119
33
  this.getEntry(),
120
34
  entryFile,
121
35
  outputDirectory,
122
- join(outputDirectory, this.outputDir, "netlify", "functions", "api")
36
+ toolsPaths,
37
+ join(outputDirectory, this.outputDir)
123
38
  );
39
+ await writeJson(join(outputDirectory, ".netlify", "v1", "config.json"), {
40
+ redirects: [
41
+ {
42
+ force: true,
43
+ from: "/*",
44
+ to: "/.netlify/functions/api/:splat",
45
+ status: 200
46
+ }
47
+ ]
48
+ });
49
+ await move(join(outputDirectory, ".netlify", "v1"), join(process.cwd(), ".netlify", "v1"), {
50
+ overwrite: true
51
+ });
52
+ return result;
124
53
  }
125
54
  getEntry() {
126
55
  return `
127
- import { handle } from 'hono/netlify'
128
- import { mastra } from '#mastra';
129
- import { createHonoServer } from '#server';
56
+ import { handle } from 'hono/netlify'
57
+ import { mastra } from '#mastra';
58
+ import { createHonoServer, getToolExports } from '#server';
59
+ import { tools } from '#tools';
60
+ import { evaluate } from '@mastra/core/eval';
61
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
62
+ import { TABLE_EVALS } from '@mastra/core/storage';
63
+ import { checkEvalStorageFields } from '@mastra/core/utils';
64
+
65
+ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
66
+ evaluate({
67
+ agentName,
68
+ input,
69
+ metric,
70
+ output,
71
+ runId,
72
+ globalRunId: runId,
73
+ instructions,
74
+ });
75
+ });
130
76
 
131
- const app = await createHonoServer(mastra);
77
+ registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
78
+ const storage = mastra.getStorage();
79
+ if (storage) {
80
+ // Check for required fields
81
+ const logger = mastra.getLogger();
82
+ const areFieldsValid = checkEvalStorageFields(traceObject, logger);
83
+ if (!areFieldsValid) return;
132
84
 
133
- export default handle(app)
85
+ await storage.insert({
86
+ tableName: TABLE_EVALS,
87
+ record: {
88
+ input: traceObject.input,
89
+ output: traceObject.output,
90
+ result: JSON.stringify(traceObject.result || {}),
91
+ agent_name: traceObject.agentName,
92
+ metric_name: traceObject.metricName,
93
+ instructions: traceObject.instructions,
94
+ test_info: null,
95
+ global_run_id: traceObject.globalRunId,
96
+ run_id: traceObject.runId,
97
+ created_at: new Date().toISOString(),
98
+ },
99
+ });
100
+ }
101
+ });
102
+
103
+ const app = await createHonoServer(mastra, { tools: getToolExports(tools) });
104
+
105
+ export default handle(app)
134
106
  `;
135
107
  }
108
+ async lint(entryFile, outputDirectory, toolsPaths) {
109
+ await super.lint(entryFile, outputDirectory, toolsPaths);
110
+ }
136
111
  };
137
112
 
138
113
  export { NetlifyDeployer };
114
+ //# sourceMappingURL=index.js.map
115
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;AAMO,IAAM,eAAA,GAAN,cAA8B,QAAA,CAAS;AAAA,EAC5C,WAAA,GAAc;AACZ,IAAA,KAAA,CAAM,EAAE,IAAA,EAAM,SAAA,EAAW,CAAA;AACzB,IAAA,IAAA,CAAK,SAAA,GAAY,IAAA,CAAK,UAAA,EAAY,IAAA,EAAM,aAAa,KAAK,CAAA;AAAA,EAC5D;AAAA,EAEA,MAAgB,mBAAA,CAAoB,eAAA,EAAyB,OAAA,GAAU,OAAA,CAAQ,KAAI,EAAG;AACpF,IAAA,MAAM,IAAA,GAAO,IAAI,WAAA,CAAY,OAAO,CAAA;AACpC,IAAA,IAAA,CAAK,WAAA,CAAY,KAAK,MAAM,CAAA;AAE5B,IAAA,MAAM,KAAK,OAAA,CAAQ;AAAA,MACjB,GAAA,EAAK,IAAA,CAAK,eAAA,EAAiB,IAAA,CAAK,SAAS,CAAA;AAAA,MACzC,YAAA,EAAc;AAAA,QACZ,EAAA,EAAI,CAAC,OAAO,CAAA;AAAA,QACZ,GAAA,EAAK,CAAC,KAAK,CAAA;AAAA,QACX,IAAA,EAAM,CAAC,KAAK;AAAA;AACd,KACD,CAAA;AAAA,EACH;AAAA,EAEA,MAAM,MAAA,GAAwB;AAC5B,IAAA,IAAA,CAAK,MAAA,EAAQ,KAAK,0EAA0E,CAAA;AAAA,EAC9F;AAAA,EAEA,MAAM,QAAQ,eAAA,EAAwC;AACpD,IAAA,MAAM,KAAA,CAAM,QAAQ,eAAe,CAAA;AAAA,EACrC;AAAA,EAEA,MAAM,MAAA,CAAO,SAAA,EAAmB,eAAA,EAAyB,UAAA,EAAkD;AACzG,IAAA,MAAM,MAAA,GAAS,MAAM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from '@mastra/deployer';\nimport { DepsService } from '@mastra/deployer/services';\nimport { move, writeJson } from 'fs-extra/esm';\n\nexport class NetlifyDeployer extends Deployer {\n constructor() {\n super({ name: 'NETLIFY' });\n this.outputDir = join('.netlify', 'v1', 'functions', 'api');\n }\n\n protected async installDependencies(outputDirectory: string, rootDir = process.cwd()) {\n const deps = new DepsService(rootDir);\n deps.__setLogger(this.logger);\n\n await deps.install({\n dir: join(outputDirectory, this.outputDir),\n architecture: {\n os: ['linux'],\n cpu: ['x64'],\n libc: ['gnu'],\n },\n });\n }\n\n async deploy(): Promise<void> {\n this.logger?.info('Deploying to Netlify failed. Please use the Netlify dashboard to deploy.');\n }\n\n async prepare(outputDirectory: string): Promise<void> {\n await super.prepare(outputDirectory);\n }\n\n async bundle(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n outputDirectory,\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n await writeJson(join(outputDirectory, '.netlify', 'v1', 'config.json'), {\n redirects: [\n {\n force: true,\n from: '/*',\n to: '/.netlify/functions/api/:splat',\n status: 200,\n },\n ],\n });\n\n await move(join(outputDirectory, '.netlify', 'v1'), join(process.cwd(), '.netlify', 'v1'), {\n overwrite: true,\n });\n\n return result;\n }\n\n private getEntry(): string {\n return `\n import { handle } from 'hono/netlify'\n import { mastra } from '#mastra';\n import { createHonoServer, getToolExports } from '#server';\n import { tools } from '#tools';\n import { evaluate } from '@mastra/core/eval';\n import { AvailableHooks, registerHook } from '@mastra/core/hooks';\n import { TABLE_EVALS } from '@mastra/core/storage';\n import { checkEvalStorageFields } from '@mastra/core/utils';\n\n registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {\n evaluate({\n agentName,\n input,\n metric,\n output,\n runId,\n globalRunId: runId,\n instructions,\n });\n });\n\n registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {\n const storage = mastra.getStorage();\n if (storage) {\n // Check for required fields\n const logger = mastra.getLogger();\n const areFieldsValid = checkEvalStorageFields(traceObject, logger);\n if (!areFieldsValid) return;\n\n await storage.insert({\n tableName: TABLE_EVALS,\n record: {\n input: traceObject.input,\n output: traceObject.output,\n result: JSON.stringify(traceObject.result || {}),\n agent_name: traceObject.agentName,\n metric_name: traceObject.metricName,\n instructions: traceObject.instructions,\n test_info: null,\n global_run_id: traceObject.globalRunId,\n run_id: traceObject.runId,\n created_at: new Date().toISOString(),\n },\n });\n }\n });\n\n const app = await createHonoServer(mastra, { tools: getToolExports(tools) });\n\n export default handle(app)\n`;\n }\n\n async lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void> {\n await super.lint(entryFile, outputDirectory, toolsPaths);\n\n // Lint for netlify support\n }\n}\n"]}
package/package.json CHANGED
@@ -1,39 +1,66 @@
1
1
  {
2
2
  "name": "@mastra/deployer-netlify",
3
- "version": "0.0.0-storage-20250225005900",
3
+ "version": "0.0.0-stream-vnext-usage-20250908171242",
4
4
  "description": "",
5
5
  "type": "module",
6
+ "files": [
7
+ "dist",
8
+ "CHANGELOG.md"
9
+ ],
6
10
  "main": "dist/index.js",
7
11
  "types": "dist/index.d.ts",
8
12
  "exports": {
9
13
  ".": {
10
- "types": "./dist/index.d.ts",
11
- "default": "./dist/index.js"
14
+ "import": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "require": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.cjs"
21
+ }
12
22
  },
13
23
  "./package.json": "./package.json"
14
24
  },
15
25
  "keywords": [],
16
26
  "author": "",
17
- "license": "ISC",
27
+ "license": "Apache-2.0",
18
28
  "dependencies": {
19
29
  "@rollup/plugin-virtual": "^3.0.2",
20
30
  "date-fns": "^4.1.0",
21
- "execa": "^9.3.1",
22
- "netlify-cli": "^18.0.1",
23
- "zod": "^3.24.1",
24
- "@mastra/core": "^0.0.0-storage-20250225005900",
25
- "@mastra/deployer": "^0.0.0-storage-20250225005900"
31
+ "execa": "^9.6.0",
32
+ "fs-extra": "^11.3.1",
33
+ "@mastra/deployer": "0.0.0-stream-vnext-usage-20250908171242"
26
34
  },
27
35
  "devDependencies": {
28
- "@microsoft/api-extractor": "^7.49.2",
29
- "@types/node": "^22.13.1",
30
- "tsup": "^8.0.1",
31
- "typescript": "^5.7.3",
32
- "vitest": "^3.0.4"
36
+ "@microsoft/api-extractor": "^7.52.8",
37
+ "@types/fs-extra": "^11.0.4",
38
+ "@types/node": "^20.19.0",
39
+ "eslint": "^9.30.1",
40
+ "tsup": "^8.5.0",
41
+ "typescript": "^5.8.3",
42
+ "vitest": "^3.2.4",
43
+ "@internal/lint": "0.0.0-stream-vnext-usage-20250908171242",
44
+ "@internal/types-builder": "0.0.0-stream-vnext-usage-20250908171242",
45
+ "@mastra/core": "0.0.0-stream-vnext-usage-20250908171242"
46
+ },
47
+ "homepage": "https://mastra.ai",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/mastra-ai/mastra.git",
51
+ "directory": "deployers/netlify"
52
+ },
53
+ "bugs": {
54
+ "url": "https://github.com/mastra-ai/mastra/issues"
55
+ },
56
+ "peerDependencies": {
57
+ "zod": "^3.25.0 || ^4.0.0",
58
+ "@mastra/core": "0.0.0-stream-vnext-usage-20250908171242"
33
59
  },
34
60
  "scripts": {
35
- "build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
36
- "build:watch": "pnpm build --watch",
37
- "test": "vitest run"
61
+ "build": "tsup --silent --config tsup.config.ts",
62
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
63
+ "test": "vitest run",
64
+ "lint": "eslint ."
38
65
  }
39
66
  }
@@ -1,19 +0,0 @@
1
-
2
- 
3
- > @mastra/deployer-netlify@0.1.5-alpha.1 build /Users/ward/projects/mastra/mastra/deployers/netlify
4
- > tsup src/index.ts --format esm --experimental-dts --clean --treeshake
5
-
6
- CLI Building entry: src/index.ts
7
- CLI Using tsconfig: tsconfig.json
8
- CLI tsup v8.3.6
9
- TSC Build start
10
- TSC ⚡️ Build success in 1897ms
11
- DTS Build start
12
- CLI Target: es2022
13
- Analysis will use the bundled TypeScript version 5.7.3
14
- Writing package typings: /Users/ward/projects/mastra/mastra/deployers/netlify/dist/_tsup-dts-rollup.d.ts
15
- DTS ⚡️ Build success in 1236ms
16
- CLI Cleaning output folder
17
- ESM Build start
18
- ESM dist/index.js 3.47 KB
19
- ESM ⚡️ Build success in 67ms
package/LICENSE DELETED
@@ -1,44 +0,0 @@
1
- Elastic License 2.0 (ELv2)
2
-
3
- **Acceptance**
4
- By using the software, you agree to all of the terms and conditions below.
5
-
6
- **Copyright License**
7
- The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
8
-
9
- **Limitations**
10
- You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
11
-
12
- You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
13
-
14
- You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
15
-
16
- **Patents**
17
- The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
18
-
19
- **Notices**
20
- You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
21
-
22
- If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
23
-
24
- **No Other Rights**
25
- These terms do not imply any licenses other than those expressly granted in these terms.
26
-
27
- **Termination**
28
- If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
29
-
30
- **No Liability**
31
- As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
32
-
33
- **Definitions**
34
- The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
35
-
36
- _you_ refers to the individual or entity agreeing to these terms.
37
-
38
- _your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
39
-
40
- _your licenses_ are all the licenses granted to you for the software under these terms.
41
-
42
- _use_ means anything you do with the software requiring one of your licenses.
43
-
44
- _trademark_ means trademarks, service marks, and similar rights.
@@ -1,38 +0,0 @@
1
- import { Deployer } from '@mastra/deployer';
2
-
3
- export declare function getOrCreateSite({ token, name, scope }: {
4
- token: string;
5
- name: string;
6
- scope: string;
7
- }): Promise<{
8
- id: string | undefined;
9
- name: string | undefined;
10
- url: string | undefined;
11
- adminUrl: string | undefined;
12
- } | {
13
- id: string;
14
- name: string;
15
- ssl_url: string;
16
- url: string;
17
- admin_url: string;
18
- }>;
19
-
20
- export declare class NetlifyDeployer extends Deployer {
21
- protected scope: string;
22
- protected projectName: string;
23
- protected token: string;
24
- constructor({ scope, projectName, token }: {
25
- scope: string;
26
- projectName: string;
27
- token: string;
28
- });
29
- writeFiles({ dir }: {
30
- dir: string;
31
- }): void;
32
- deploy(outputDirectory: string): Promise<void>;
33
- prepare(outputDirectory: string): Promise<void>;
34
- bundle(entryFile: string, outputDirectory: string): Promise<void>;
35
- private getEntry;
36
- }
37
-
38
- export { }