@mastra/deployer-netlify 0.0.0-fix-memory-xxhash-20250409202110 → 0.0.0-fix-generate-title-20250616171351

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.
@@ -1,4 +1,6 @@
1
- Elastic License 2.0 (ELv2)
1
+ # Elastic License 2.0 (ELv2)
2
+
3
+ Copyright (c) 2025 Mastra AI, Inc.
2
4
 
3
5
  **Acceptance**
4
6
  By using the software, you agree to all of the terms and conditions below.
@@ -1,22 +1,5 @@
1
1
  import { Deployer } from '@mastra/deployer';
2
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
3
  export declare class NetlifyDeployer extends Deployer {
21
4
  protected scope: string;
22
5
  protected projectName: string;
@@ -29,10 +12,12 @@ export declare class NetlifyDeployer extends Deployer {
29
12
  writeFiles({ dir }: {
30
13
  dir: string;
31
14
  }): void;
32
- deploy(outputDirectory: string): Promise<void>;
15
+ protected installDependencies(outputDirectory: string, rootDir?: string): Promise<void>;
16
+ deploy(): Promise<void>;
33
17
  prepare(outputDirectory: string): Promise<void>;
34
- bundle(entryFile: string, outputDirectory: string): Promise<void>;
18
+ bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
35
19
  private getEntry;
20
+ lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
36
21
  }
37
22
 
38
23
  export { }
@@ -1,22 +1,5 @@
1
1
  import { Deployer } from '@mastra/deployer';
2
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
3
  export declare class NetlifyDeployer extends Deployer {
21
4
  protected scope: string;
22
5
  protected projectName: string;
@@ -29,10 +12,12 @@ export declare class NetlifyDeployer extends Deployer {
29
12
  writeFiles({ dir }: {
30
13
  dir: string;
31
14
  }): void;
32
- deploy(outputDirectory: string): Promise<void>;
15
+ protected installDependencies(outputDirectory: string, rootDir?: string): Promise<void>;
16
+ deploy(): Promise<void>;
33
17
  prepare(outputDirectory: string): Promise<void>;
34
- bundle(entryFile: string, outputDirectory: string): Promise<void>;
18
+ bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
35
19
  private getEntry;
20
+ lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
36
21
  }
37
22
 
38
23
  export { }
package/dist/index.cjs CHANGED
@@ -3,62 +3,7 @@
3
3
  var fs = require('fs');
4
4
  var path = require('path');
5
5
  var deployer = require('@mastra/deployer');
6
- var execa = require('execa');
7
-
8
- // src/index.ts
9
-
10
- // src/helpers.ts
11
- async function createNetlifySite({ token, name, scope }) {
12
- const response = await fetch("https://api.netlify.com/api/v1/sites", {
13
- method: "POST",
14
- headers: {
15
- Authorization: `Bearer ${token}`,
16
- "Content-Type": "application/json"
17
- },
18
- body: JSON.stringify({
19
- name,
20
- account_slug: scope,
21
- // Optional - if not provided, creates in user's default account
22
- force_ssl: true
23
- // Enable HTTPS
24
- })
25
- });
26
- const data = await response.json();
27
- if (!response.ok) {
28
- console.error(JSON.stringify(data));
29
- throw new Error(`Failed to create site: ${data.message || "Unknown error"}`);
30
- }
31
- return {
32
- id: data.id,
33
- name: data.name,
34
- url: data.ssl_url || data.url,
35
- adminUrl: data.admin_url
36
- };
37
- }
38
- async function findNetlifySite({ token, name, scope }) {
39
- const response = await fetch(`https://api.netlify.com/api/v1/${scope}/sites?filter=all&name=${name}`, {
40
- headers: {
41
- Authorization: `Bearer ${token}`,
42
- "Content-Type": "application/json"
43
- }
44
- });
45
- const data = await response.json();
46
- if (!response.ok || !Array.isArray(data)) {
47
- throw new Error(`Failed to search sites: ${data.message || "Unknown error"}`);
48
- }
49
- return data.find((site) => site.name === name);
50
- }
51
- async function getOrCreateSite({ token, name, scope }) {
52
- let existingSite;
53
- try {
54
- existingSite = await findNetlifySite({ token, name, scope });
55
- } catch {
56
- }
57
- if (existingSite) {
58
- return existingSite;
59
- }
60
- return createNetlifySite({ token, name, scope });
61
- }
6
+ var services = require('@mastra/deployer/services');
62
7
 
63
8
  // src/index.ts
64
9
  var NetlifyDeployer = class extends deployer.Deployer {
@@ -89,52 +34,90 @@ to = "/.netlify/functions/api/:splat"
89
34
  `
90
35
  );
91
36
  }
92
- async deploy(outputDirectory) {
93
- const site = await getOrCreateSite({ token: this.token, name: this.projectName || `mastra`, scope: this.scope });
94
- const p2 = execa.execa(
95
- "npx",
96
- [
97
- "netlify-cli",
98
- "deploy",
99
- "--site",
100
- site.id,
101
- "--auth",
102
- this.token,
103
- "--dir",
104
- ".",
105
- "--functions",
106
- "./netlify/functions"
107
- ],
108
- {
109
- cwd: path.join(outputDirectory, this.outputDir)
37
+ async installDependencies(outputDirectory, rootDir = process.cwd()) {
38
+ const deps = new services.DepsService(rootDir);
39
+ deps.__setLogger(this.logger);
40
+ await deps.install({
41
+ dir: path.join(outputDirectory, this.outputDir),
42
+ architecture: {
43
+ os: ["linux"],
44
+ cpu: ["x64"],
45
+ libc: ["gnu"]
110
46
  }
111
- );
112
- p2.stdout.pipe(process.stdout);
113
- await p2;
47
+ });
48
+ }
49
+ async deploy() {
50
+ this.logger?.info("Deploying to Netlify failed. Please use the Netlify dashboard to deploy.");
114
51
  }
115
52
  async prepare(outputDirectory) {
116
53
  await super.prepare(outputDirectory);
117
54
  this.writeFiles({ dir: path.join(outputDirectory, this.outputDir) });
118
55
  }
119
- async bundle(entryFile, outputDirectory) {
56
+ async bundle(entryFile, outputDirectory, toolsPaths) {
120
57
  return this._bundle(
121
58
  this.getEntry(),
122
59
  entryFile,
123
60
  outputDirectory,
61
+ toolsPaths,
124
62
  path.join(outputDirectory, this.outputDir, "netlify", "functions", "api")
125
63
  );
126
64
  }
127
65
  getEntry() {
128
66
  return `
129
- import { handle } from 'hono/netlify'
130
- import { mastra } from '#mastra';
131
- import { createHonoServer } from '#server';
67
+ import { handle } from 'hono/netlify'
68
+ import { mastra } from '#mastra';
69
+ import { createHonoServer } from '#server';
70
+ import { evaluate } from '@mastra/core/eval';
71
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
72
+ import { TABLE_EVALS } from '@mastra/core/storage';
73
+ import { checkEvalStorageFields } from '@mastra/core/utils';
132
74
 
133
- const app = await createHonoServer(mastra);
75
+ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
76
+ evaluate({
77
+ agentName,
78
+ input,
79
+ metric,
80
+ output,
81
+ runId,
82
+ globalRunId: runId,
83
+ instructions,
84
+ });
85
+ });
134
86
 
135
- export default handle(app)
87
+ registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
88
+ const storage = mastra.getStorage();
89
+ if (storage) {
90
+ // Check for required fields
91
+ const logger = mastra.getLogger();
92
+ const areFieldsValid = checkEvalStorageFields(traceObject, logger);
93
+ if (!areFieldsValid) return;
94
+
95
+ await storage.insert({
96
+ tableName: TABLE_EVALS,
97
+ record: {
98
+ input: traceObject.input,
99
+ output: traceObject.output,
100
+ result: JSON.stringify(traceObject.result || {}),
101
+ agent_name: traceObject.agentName,
102
+ metric_name: traceObject.metricName,
103
+ instructions: traceObject.instructions,
104
+ test_info: null,
105
+ global_run_id: traceObject.globalRunId,
106
+ run_id: traceObject.runId,
107
+ created_at: new Date().toISOString(),
108
+ },
109
+ });
110
+ }
111
+ });
112
+
113
+ const app = await createHonoServer(mastra);
114
+
115
+ export default handle(app)
136
116
  `;
137
117
  }
118
+ async lint(entryFile, outputDirectory, toolsPaths) {
119
+ await super.lint(entryFile, outputDirectory, toolsPaths);
120
+ }
138
121
  };
139
122
 
140
123
  exports.NetlifyDeployer = NetlifyDeployer;
package/dist/index.js CHANGED
@@ -1,62 +1,7 @@
1
1
  import { existsSync, mkdirSync, writeFileSync } from 'fs';
2
2
  import { join } from 'path';
3
3
  import { Deployer } from '@mastra/deployer';
4
- import { execa } from 'execa';
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 {
54
- }
55
- if (existingSite) {
56
- return existingSite;
57
- }
58
- return createNetlifySite({ token, name, scope });
59
- }
4
+ import { DepsService } from '@mastra/deployer/services';
60
5
 
61
6
  // src/index.ts
62
7
  var NetlifyDeployer = class extends Deployer {
@@ -87,52 +32,90 @@ to = "/.netlify/functions/api/:splat"
87
32
  `
88
33
  );
89
34
  }
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)
35
+ async installDependencies(outputDirectory, rootDir = process.cwd()) {
36
+ const deps = new DepsService(rootDir);
37
+ deps.__setLogger(this.logger);
38
+ await deps.install({
39
+ dir: join(outputDirectory, this.outputDir),
40
+ architecture: {
41
+ os: ["linux"],
42
+ cpu: ["x64"],
43
+ libc: ["gnu"]
108
44
  }
109
- );
110
- p2.stdout.pipe(process.stdout);
111
- await p2;
45
+ });
46
+ }
47
+ async deploy() {
48
+ this.logger?.info("Deploying to Netlify failed. Please use the Netlify dashboard to deploy.");
112
49
  }
113
50
  async prepare(outputDirectory) {
114
51
  await super.prepare(outputDirectory);
115
52
  this.writeFiles({ dir: join(outputDirectory, this.outputDir) });
116
53
  }
117
- async bundle(entryFile, outputDirectory) {
54
+ async bundle(entryFile, outputDirectory, toolsPaths) {
118
55
  return this._bundle(
119
56
  this.getEntry(),
120
57
  entryFile,
121
58
  outputDirectory,
59
+ toolsPaths,
122
60
  join(outputDirectory, this.outputDir, "netlify", "functions", "api")
123
61
  );
124
62
  }
125
63
  getEntry() {
126
64
  return `
127
- import { handle } from 'hono/netlify'
128
- import { mastra } from '#mastra';
129
- import { createHonoServer } from '#server';
65
+ import { handle } from 'hono/netlify'
66
+ import { mastra } from '#mastra';
67
+ import { createHonoServer } from '#server';
68
+ import { evaluate } from '@mastra/core/eval';
69
+ import { AvailableHooks, registerHook } from '@mastra/core/hooks';
70
+ import { TABLE_EVALS } from '@mastra/core/storage';
71
+ import { checkEvalStorageFields } from '@mastra/core/utils';
130
72
 
131
- const app = await createHonoServer(mastra);
73
+ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
74
+ evaluate({
75
+ agentName,
76
+ input,
77
+ metric,
78
+ output,
79
+ runId,
80
+ globalRunId: runId,
81
+ instructions,
82
+ });
83
+ });
132
84
 
133
- export default handle(app)
85
+ registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
86
+ const storage = mastra.getStorage();
87
+ if (storage) {
88
+ // Check for required fields
89
+ const logger = mastra.getLogger();
90
+ const areFieldsValid = checkEvalStorageFields(traceObject, logger);
91
+ if (!areFieldsValid) return;
92
+
93
+ await storage.insert({
94
+ tableName: TABLE_EVALS,
95
+ record: {
96
+ input: traceObject.input,
97
+ output: traceObject.output,
98
+ result: JSON.stringify(traceObject.result || {}),
99
+ agent_name: traceObject.agentName,
100
+ metric_name: traceObject.metricName,
101
+ instructions: traceObject.instructions,
102
+ test_info: null,
103
+ global_run_id: traceObject.globalRunId,
104
+ run_id: traceObject.runId,
105
+ created_at: new Date().toISOString(),
106
+ },
107
+ });
108
+ }
109
+ });
110
+
111
+ const app = await createHonoServer(mastra);
112
+
113
+ export default handle(app)
134
114
  `;
135
115
  }
116
+ async lint(entryFile, outputDirectory, toolsPaths) {
117
+ await super.lint(entryFile, outputDirectory, toolsPaths);
118
+ }
136
119
  };
137
120
 
138
121
  export { NetlifyDeployer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer-netlify",
3
- "version": "0.0.0-fix-memory-xxhash-20250409202110",
3
+ "version": "0.0.0-fix-generate-title-20250616171351",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -23,24 +23,26 @@
23
23
  },
24
24
  "keywords": [],
25
25
  "author": "",
26
- "license": "ISC",
26
+ "license": "Elastic-2.0",
27
27
  "dependencies": {
28
28
  "@rollup/plugin-virtual": "^3.0.2",
29
29
  "date-fns": "^4.1.0",
30
- "execa": "^9.5.2",
31
- "netlify-cli": "^19.0.3",
32
- "zod": "^3.24.2",
33
- "@mastra/core": "0.0.0-fix-memory-xxhash-20250409202110",
34
- "@mastra/deployer": "0.0.0-fix-memory-xxhash-20250409202110"
30
+ "execa": "^9.6.0",
31
+ "zod": "^3.25.57",
32
+ "@mastra/deployer": "0.0.0-fix-generate-title-20250616171351"
35
33
  },
36
34
  "devDependencies": {
37
- "@microsoft/api-extractor": "^7.52.1",
38
- "@types/node": "^20.17.27",
39
- "eslint": "^9.23.0",
40
- "tsup": "^8.4.0",
41
- "typescript": "^5.8.2",
42
- "vitest": "^3.0.9",
43
- "@internal/lint": "0.0.1"
35
+ "@microsoft/api-extractor": "^7.52.8",
36
+ "@types/node": "^20.19.0",
37
+ "eslint": "^9.28.0",
38
+ "tsup": "^8.5.0",
39
+ "typescript": "^5.8.3",
40
+ "vitest": "^3.2.3",
41
+ "@mastra/core": "0.0.0-fix-generate-title-20250616171351",
42
+ "@internal/lint": "0.0.0-fix-generate-title-20250616171351"
43
+ },
44
+ "peerDependencies": {
45
+ "@mastra/core": "0.0.0-fix-generate-title-20250616171351"
44
46
  },
45
47
  "scripts": {
46
48
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",