@mastra/deployer-netlify 0.0.0-trigger-playground-ui-package-20250506151043 → 0.0.0-type-testing-20260120105120

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/dist/index.js CHANGED
@@ -1,92 +1,14 @@
1
- import { existsSync, mkdirSync, writeFileSync } from 'fs';
2
1
  import { join } from 'path';
2
+ import process from 'process';
3
3
  import { Deployer } from '@mastra/deployer';
4
4
  import { DepsService } from '@mastra/deployer/services';
5
- import { execa } from 'execa';
6
-
7
- // src/index.ts
8
-
9
- // src/helpers.ts
10
- async function createNetlifySite({ token, name, scope }) {
11
- const response = await fetch("https://api.netlify.com/api/v1/sites", {
12
- method: "POST",
13
- headers: {
14
- Authorization: `Bearer ${token}`,
15
- "Content-Type": "application/json"
16
- },
17
- body: JSON.stringify({
18
- name,
19
- account_slug: scope,
20
- // Optional - if not provided, creates in user's default account
21
- force_ssl: true
22
- // Enable HTTPS
23
- })
24
- });
25
- const data = await response.json();
26
- if (!response.ok) {
27
- console.error(JSON.stringify(data));
28
- throw new Error(`Failed to create site: ${data.message || "Unknown error"}`);
29
- }
30
- return {
31
- id: data.id,
32
- name: data.name,
33
- url: data.ssl_url || data.url,
34
- adminUrl: data.admin_url
35
- };
36
- }
37
- async function findNetlifySite({ token, name, scope }) {
38
- const response = await fetch(`https://api.netlify.com/api/v1/${scope}/sites?filter=all&name=${name}`, {
39
- headers: {
40
- Authorization: `Bearer ${token}`,
41
- "Content-Type": "application/json"
42
- }
43
- });
44
- const data = await response.json();
45
- if (!response.ok || !Array.isArray(data)) {
46
- throw new Error(`Failed to search sites: ${data.message || "Unknown error"}`);
47
- }
48
- return data.find((site) => site.name === name);
49
- }
50
- async function getOrCreateSite({ token, name, scope }) {
51
- let existingSite;
52
- try {
53
- existingSite = await findNetlifySite({ token, name, scope });
54
- } catch {
55
- }
56
- if (existingSite) {
57
- return existingSite;
58
- }
59
- return createNetlifySite({ token, name, scope });
60
- }
5
+ import { writeJson, move } from 'fs-extra/esm';
61
6
 
62
7
  // src/index.ts
63
8
  var NetlifyDeployer = class extends Deployer {
64
- scope;
65
- projectName;
66
- token;
67
- constructor({ scope, projectName, token }) {
9
+ constructor() {
68
10
  super({ name: "NETLIFY" });
69
- this.scope = scope;
70
- this.projectName = projectName;
71
- this.token = token;
72
- }
73
- writeFiles({ dir }) {
74
- if (!existsSync(join(dir, "netlify/functions/api"))) {
75
- mkdirSync(join(dir, "netlify/functions/api"), { recursive: true });
76
- }
77
- writeFileSync(
78
- join(dir, "netlify.toml"),
79
- `[functions]
80
- node_bundler = "esbuild"
81
- directory = "netlify/functions"
82
-
83
- [[redirects]]
84
- force = true
85
- from = "/*"
86
- status = 200
87
- to = "/.netlify/functions/api/:splat"
88
- `
89
- );
11
+ this.outputDir = join(".netlify", "v1", "functions", "api");
90
12
  }
91
13
  async installDependencies(outputDirectory, rootDir = process.cwd()) {
92
14
  const deps = new DepsService(rootDir);
@@ -100,103 +22,71 @@ to = "/.netlify/functions/api/:splat"
100
22
  }
101
23
  });
102
24
  }
103
- async deploy(outputDirectory) {
104
- const site = await getOrCreateSite({ token: this.token, name: this.projectName || `mastra`, scope: this.scope });
105
- const p2 = execa(
106
- "npx",
107
- [
108
- "netlify-cli",
109
- "deploy",
110
- "--site",
111
- site.id,
112
- "--auth",
113
- this.token,
114
- "--dir",
115
- ".",
116
- "--functions",
117
- "./netlify/functions"
118
- ],
119
- {
120
- cwd: join(outputDirectory, this.outputDir)
121
- }
122
- );
123
- p2.stdout.pipe(process.stdout);
124
- await p2;
25
+ async deploy() {
26
+ this.logger?.info("Deploying to Netlify failed. Please use the Netlify dashboard to deploy.");
125
27
  }
126
28
  async prepare(outputDirectory) {
127
29
  await super.prepare(outputDirectory);
128
- this.writeFiles({ dir: join(outputDirectory, this.outputDir) });
129
30
  }
130
- async bundle(entryFile, outputDirectory, toolsPaths) {
131
- return this._bundle(
31
+ async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
32
+ const result = await this._bundle(
132
33
  this.getEntry(),
133
34
  entryFile,
134
- outputDirectory,
35
+ { outputDirectory, projectRoot, enableEsmShim: true },
135
36
  toolsPaths,
136
- join(outputDirectory, this.outputDir, "netlify", "functions", "api")
37
+ join(outputDirectory, this.outputDir)
137
38
  );
39
+ await writeJson(join(outputDirectory, ".netlify", "v1", "config.json"), {
40
+ functions: {
41
+ directory: ".netlify/v1/functions",
42
+ node_bundler: "none",
43
+ // Mastra pre-bundles, don't re-bundle
44
+ included_files: [".netlify/v1/functions/**"]
45
+ },
46
+ redirects: [
47
+ {
48
+ force: true,
49
+ from: "/*",
50
+ to: "/.netlify/functions/api/:splat",
51
+ status: 200
52
+ }
53
+ ]
54
+ });
55
+ await move(join(outputDirectory, ".netlify", "v1"), join(process.cwd(), ".netlify", "v1"), {
56
+ overwrite: true
57
+ });
58
+ return result;
138
59
  }
139
60
  getEntry() {
140
61
  return `
141
62
  import { handle } from 'hono/netlify'
142
63
  import { mastra } from '#mastra';
143
- import { createHonoServer } from '#server';
144
- import { evaluate } from '@mastra/core/eval';
145
- import { AvailableHooks, registerHook } from '@mastra/core/hooks';
146
- import { TABLE_EVALS } from '@mastra/core/storage';
147
- import { checkEvalStorageFields } from '@mastra/core/utils';
148
-
149
- registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
150
- evaluate({
151
- agentName,
152
- input,
153
- metric,
154
- output,
155
- runId,
156
- globalRunId: runId,
157
- instructions,
158
- });
159
- });
64
+ import { createHonoServer, getToolExports } from '#server';
65
+ import { tools } from '#tools';
66
+ import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';
160
67
 
161
68
  if (mastra.getStorage()) {
162
- // start storage init in the background
163
- mastra.getStorage().init();
69
+ mastra.__registerInternalWorkflow(scoreTracesWorkflow);
164
70
  }
165
71
 
166
- registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
167
- const storage = mastra.getStorage();
168
- if (storage) {
169
- // Check for required fields
170
- const logger = mastra?.getLogger();
171
- const areFieldsValid = checkEvalStorageFields(traceObject, logger);
172
- if (!areFieldsValid) return;
173
-
174
- await storage.insert({
175
- tableName: TABLE_EVALS,
176
- record: {
177
- input: traceObject.input,
178
- output: traceObject.output,
179
- result: JSON.stringify(traceObject.result || {}),
180
- agent_name: traceObject.agentName,
181
- metric_name: traceObject.metricName,
182
- instructions: traceObject.instructions,
183
- test_info: null,
184
- global_run_id: traceObject.globalRunId,
185
- run_id: traceObject.runId,
186
- created_at: new Date().toISOString(),
187
- },
188
- });
189
- }
190
- });
191
-
192
- const app = await createHonoServer(mastra);
72
+ const app = await createHonoServer(mastra, { tools: getToolExports(tools) });
193
73
 
194
74
  export default handle(app)
195
75
  `;
196
76
  }
197
77
  async lint(entryFile, outputDirectory, toolsPaths) {
198
78
  await super.lint(entryFile, outputDirectory, toolsPaths);
79
+ const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
80
+ if (hasLibsql) {
81
+ this.logger?.error(
82
+ `Netlify Deployer does not support @libsql/client (which may have been installed by @mastra/libsql) as a dependency.
83
+ LibSQL with file URLs uses native Node.js bindings that cannot run in serverless environments. Use other Mastra Storage options instead.`
84
+ );
85
+ process.exit(1);
86
+ }
199
87
  }
200
88
  };
201
89
 
202
90
  export { NetlifyDeployer };
91
+ //# sourceMappingURL=index.js.map
92
+ //# 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,CA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AAO,IAAA;AAAA,UACP,IAAA,EAAM,IAAA;AAAA,UACN,EAAA,EAAI,gCAAA;AAAA,UACJ,MAAA,EAAQ;AAAA;AACV;AACF,KACD,CAAA;AAED,IAAA,MAAM,IAAA,CAAK,IAAA,CAAK,eAAA,EAAiB,UAAA,EAAY,IAAI,CAAA,EAAG,IAAA,CAAK,OAAA,CAAQ,GAAA,EAAI,EAAG,UAAA,EAAY,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,CAAA;AAAA,EAeT;AAAA,EAEA,MAAM,IAAA,CAAK,SAAA,EAAmB,eAAA,EAAyB,UAAA,EAAkD;AACvG,IAAA,MAAM,KAAA,CAAM,IAAA,CAAK,SAAA,EAAW,eAAA,EAAiB,UAAU,CAAA;AAGvD,IAAA,MAAM,SAAA,GAAa,MAAM,IAAA,CAAK,IAAA,CAAK,kBAAkB,CAAC,gBAAgB,CAAC,CAAA,KAAO,CAAA,EAAA,CAAA;AAE9E,IAAA,IAAI,SAAA,EAAW;AACb,MAAA,IAAA,CAAK,MAAA,EAAQ,KAAA;AAAA,QACX,CAAA;AAAA,gJAAA;AAAA,OAEF;AACA,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB;AAAA,EACF;AACF","file":"index.js","sourcesContent":["import { join } from 'node:path';\nimport process from 'node: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(\n entryFile: string,\n outputDirectory: string,\n { toolsPaths, projectRoot }: { toolsPaths: (string | string[])[]; projectRoot: string },\n ): Promise<void> {\n const result = await this._bundle(\n this.getEntry(),\n entryFile,\n { outputDirectory, projectRoot, enableEsmShim: true },\n toolsPaths,\n join(outputDirectory, this.outputDir),\n );\n\n // Use Netlify Frameworks API config.json\n // https://docs.netlify.com/build/frameworks/frameworks-api/\n await writeJson(join(outputDirectory, '.netlify', 'v1', 'config.json'), {\n functions: {\n directory: '.netlify/v1/functions',\n node_bundler: 'none', // Mastra pre-bundles, don't re-bundle\n included_files: ['.netlify/v1/functions/**'],\n },\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 { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';\n\n if (mastra.getStorage()) {\n mastra.__registerInternalWorkflow(scoreTracesWorkflow);\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 // Check for LibSQL dependency which is not supported in Netlify Functions\n const hasLibsql = (await this.deps.checkDependencies(['@mastra/libsql'])) === `ok`;\n\n if (hasLibsql) {\n this.logger?.error(\n `Netlify Deployer does not support @libsql/client (which may have been installed by @mastra/libsql) as a dependency.\n LibSQL with file URLs uses native Node.js bindings that cannot run in serverless environments. Use other Mastra Storage options instead.`,\n );\n process.exit(1);\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@mastra/deployer-netlify",
3
- "version": "0.0.0-trigger-playground-ui-package-20250506151043",
3
+ "version": "0.0.0-type-testing-20260120105120",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
7
- "dist"
7
+ "dist",
8
+ "CHANGELOG.md"
8
9
  ],
9
10
  "main": "dist/index.js",
10
11
  "types": "dist/index.d.ts",
@@ -15,7 +16,7 @@
15
16
  "default": "./dist/index.js"
16
17
  },
17
18
  "require": {
18
- "types": "./dist/index.d.cts",
19
+ "types": "./dist/index.d.ts",
19
20
  "default": "./dist/index.cjs"
20
21
  }
21
22
  },
@@ -23,28 +24,43 @@
23
24
  },
24
25
  "keywords": [],
25
26
  "author": "",
26
- "license": "Elastic-2.0",
27
+ "license": "Apache-2.0",
27
28
  "dependencies": {
28
- "@rollup/plugin-virtual": "^3.0.2",
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-trigger-playground-ui-package-20250506151043",
34
- "@mastra/deployer": "0.0.0-trigger-playground-ui-package-20250506151043"
29
+ "fs-extra": "^11.3.3",
30
+ "@mastra/deployer": "0.0.0-type-testing-20260120105120"
35
31
  },
36
32
  "devDependencies": {
37
- "@microsoft/api-extractor": "^7.52.5",
38
- "@types/node": "^20.17.27",
39
- "eslint": "^9.23.0",
40
- "tsup": "^8.4.0",
41
- "typescript": "^5.8.2",
42
- "vitest": "^3.1.2",
43
- "@internal/lint": "0.0.0-trigger-playground-ui-package-20250506151043"
33
+ "@types/fs-extra": "^11.0.4",
34
+ "@types/node": "22.13.17",
35
+ "@vitest/coverage-v8": "4.0.12",
36
+ "@vitest/ui": "4.0.12",
37
+ "eslint": "^9.37.0",
38
+ "tsup": "^8.5.0",
39
+ "typescript": "^5.9.3",
40
+ "vitest": "4.0.16",
41
+ "@internal/lint": "0.0.0-type-testing-20260120105120",
42
+ "@internal/types-builder": "0.0.0-type-testing-20260120105120",
43
+ "@mastra/core": "0.0.0-type-testing-20260120105120"
44
+ },
45
+ "homepage": "https://mastra.ai",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/mastra-ai/mastra.git",
49
+ "directory": "deployers/netlify"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/mastra-ai/mastra/issues"
53
+ },
54
+ "peerDependencies": {
55
+ "zod": "^3.25.0 || ^4.0.0",
56
+ "@mastra/core": "0.0.0-type-testing-20260120105120"
57
+ },
58
+ "engines": {
59
+ "node": ">=22.13.0"
44
60
  },
45
61
  "scripts": {
46
- "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
47
- "build:watch": "pnpm build --watch",
62
+ "build": "tsup --silent --config tsup.config.ts",
63
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
48
64
  "test": "vitest run",
49
65
  "lint": "eslint ."
50
66
  }
@@ -1,40 +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
- protected installDependencies(outputDirectory: string, rootDir?: string): Promise<void>;
33
- deploy(outputDirectory: string): Promise<void>;
34
- prepare(outputDirectory: string): Promise<void>;
35
- bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
36
- private getEntry;
37
- lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
38
- }
39
-
40
- export { }
@@ -1,40 +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
- protected installDependencies(outputDirectory: string, rootDir?: string): Promise<void>;
33
- deploy(outputDirectory: string): Promise<void>;
34
- prepare(outputDirectory: string): Promise<void>;
35
- bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
36
- private getEntry;
37
- lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
38
- }
39
-
40
- export { }
package/dist/index.d.cts DELETED
@@ -1 +0,0 @@
1
- export { NetlifyDeployer } from './_tsup-dts-rollup.cjs';