@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/CHANGELOG.md +4071 -0
- package/LICENSE.md +11 -42
- package/README.md +60 -46
- package/dist/index.cjs +48 -154
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -155
- package/dist/index.js.map +1 -0
- package/package.json +36 -20
- package/dist/_tsup-dts-rollup.d.cts +0 -40
- package/dist/_tsup-dts-rollup.d.ts +0 -40
- package/dist/index.d.cts +0 -1
package/LICENSE.md
CHANGED
|
@@ -1,46 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Apache License 2.0
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
3
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
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
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
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.
|
|
17
|
-
|
|
18
|
-
**Patents**
|
|
19
|
-
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.
|
|
20
|
-
|
|
21
|
-
**Notices**
|
|
22
|
-
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
23
|
-
|
|
24
|
-
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
25
|
-
|
|
26
|
-
**No Other Rights**
|
|
27
|
-
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
28
|
-
|
|
29
|
-
**Termination**
|
|
30
|
-
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.
|
|
31
|
-
|
|
32
|
-
**No Liability**
|
|
33
|
-
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.
|
|
34
|
-
|
|
35
|
-
**Definitions**
|
|
36
|
-
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.
|
|
37
|
-
|
|
38
|
-
_you_ refers to the individual or entity agreeing to these terms.
|
|
39
|
-
|
|
40
|
-
_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.
|
|
41
|
-
|
|
42
|
-
_your licenses_ are all the licenses granted to you for the software under these terms.
|
|
43
|
-
|
|
44
|
-
_use_ means anything you do with the software requiring one of your licenses.
|
|
45
|
-
|
|
46
|
-
_trademark_ means trademarks, service marks, and similar rights.
|
|
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
|
@@ -5,14 +5,14 @@ A Netlify deployer for Mastra applications.
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- Deploy Mastra applications to Netlify Functions
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
8
|
+
- Generates Netlify Frameworks API configuration during build
|
|
9
|
+
- Bundles functions with optimized settings for serverless environments
|
|
10
|
+
- Routes all requests through a single API endpoint
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
|
|
15
|
+
npm install @mastra/deployer-netlify
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
@@ -20,69 +20,83 @@ pnpm add @mastra/deployer-netlify
|
|
|
20
20
|
The Netlify deployer is used as part of the Mastra framework:
|
|
21
21
|
|
|
22
22
|
```typescript
|
|
23
|
-
import { Mastra } from '@mastra/core';
|
|
23
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
24
24
|
import { NetlifyDeployer } from '@mastra/deployer-netlify';
|
|
25
25
|
|
|
26
|
-
const deployer = new NetlifyDeployer({
|
|
27
|
-
scope: 'your-team-id',
|
|
28
|
-
projectName: 'your-project-name',
|
|
29
|
-
token: 'your-netlify-token',
|
|
30
|
-
});
|
|
31
|
-
|
|
32
26
|
const mastra = new Mastra({
|
|
33
|
-
deployer,
|
|
34
|
-
// ... other Mastra configuration options
|
|
27
|
+
deployer: new NetlifyDeployer(),
|
|
35
28
|
});
|
|
36
29
|
```
|
|
37
30
|
|
|
38
|
-
## Configuration
|
|
39
|
-
|
|
40
|
-
### Constructor Options
|
|
41
|
-
|
|
42
|
-
- `scope` (required): Your Netlify team slug or ID
|
|
43
|
-
- `projectName`: Name of your Netlify site (will be created if it doesn't exist)
|
|
44
|
-
- `token`: Your Netlify authentication token
|
|
45
|
-
|
|
46
31
|
## Project Structure
|
|
47
32
|
|
|
48
33
|
The deployer automatically creates the following structure:
|
|
49
34
|
|
|
50
|
-
```
|
|
35
|
+
```bash
|
|
51
36
|
your-project/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
└──
|
|
37
|
+
└── .netlify/
|
|
38
|
+
└── v1/
|
|
39
|
+
├── config.json
|
|
40
|
+
└── functions/
|
|
41
|
+
└── api/
|
|
42
|
+
├── index.js
|
|
43
|
+
├── package.json
|
|
44
|
+
└── node_modules/
|
|
56
45
|
```
|
|
57
46
|
|
|
58
|
-
###
|
|
47
|
+
### Netlify Frameworks API Configuration
|
|
48
|
+
|
|
49
|
+
The deployer uses Netlify's [Frameworks API](https://docs.netlify.com/build/frameworks/frameworks-api/) and generates a `.netlify/v1/config.json` file to configure functions and routing for Netlify.
|
|
50
|
+
|
|
51
|
+
Generated configuration:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"functions": {
|
|
56
|
+
"directory": ".netlify/v1/functions",
|
|
57
|
+
"node_bundler": "none",
|
|
58
|
+
"included_files": [".netlify/v1/functions/**"]
|
|
59
|
+
},
|
|
60
|
+
"redirects": [
|
|
61
|
+
{
|
|
62
|
+
"force": true,
|
|
63
|
+
"from": "/*",
|
|
64
|
+
"to": "/.netlify/functions/api/:splat",
|
|
65
|
+
"status": 200
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
59
70
|
|
|
60
|
-
|
|
71
|
+
This configuration:
|
|
61
72
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
directory = "/netlify/functions"
|
|
73
|
+
- Tells Netlify where to find your functions
|
|
74
|
+
- Disables Netlify's bundling (Mastra pre-bundles for optimization)
|
|
75
|
+
- Routes all requests to your Mastra API function
|
|
66
76
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
## How It Works
|
|
78
|
+
|
|
79
|
+
The Netlify deployer:
|
|
80
|
+
|
|
81
|
+
1. **Bundles your Mastra application** into optimized serverless functions
|
|
82
|
+
2. **Creates the Frameworks API configuration** automatically
|
|
83
|
+
3. **Handles all routing** through a single API endpoint
|
|
84
|
+
4. **Pre-optimizes dependencies** for serverless environments
|
|
73
85
|
|
|
74
86
|
## Environment Variables
|
|
75
87
|
|
|
76
|
-
Environment variables are handled
|
|
88
|
+
Environment variables are handled through:
|
|
77
89
|
|
|
78
90
|
- `.env` files in your project
|
|
79
|
-
-
|
|
80
|
-
-
|
|
91
|
+
- Netlify's environment variable dashboard
|
|
92
|
+
- Runtime environment variable access in your Mastra app
|
|
93
|
+
|
|
94
|
+
## Deployment
|
|
81
95
|
|
|
82
|
-
|
|
96
|
+
Deploy your Mastra application to Netlify by:
|
|
83
97
|
|
|
84
|
-
|
|
98
|
+
1. **Building locally**: Run your build command (the deployer handles bundling)
|
|
99
|
+
2. **Using Netlify CLI**: `netlify deploy --prod`
|
|
100
|
+
3. **Via Git integration**: Connect your repository to Netlify for automatic deployments
|
|
85
101
|
|
|
86
|
-
|
|
87
|
-
2. Configure the site with your environment variables
|
|
88
|
-
3. Deploy your application to Netlify Functions
|
|
102
|
+
The deployer automatically configures everything needed for Netlify Functions.
|
package/dist/index.cjs
CHANGED
|
@@ -1,96 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var fs = require('fs');
|
|
4
3
|
var path = require('path');
|
|
4
|
+
var process = require('process');
|
|
5
5
|
var deployer = require('@mastra/deployer');
|
|
6
6
|
var services = require('@mastra/deployer/services');
|
|
7
|
-
var
|
|
7
|
+
var esm = require('fs-extra/esm');
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
async function createNetlifySite({ token, name, scope }) {
|
|
13
|
-
const response = await fetch("https://api.netlify.com/api/v1/sites", {
|
|
14
|
-
method: "POST",
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `Bearer ${token}`,
|
|
17
|
-
"Content-Type": "application/json"
|
|
18
|
-
},
|
|
19
|
-
body: JSON.stringify({
|
|
20
|
-
name,
|
|
21
|
-
account_slug: scope,
|
|
22
|
-
// Optional - if not provided, creates in user's default account
|
|
23
|
-
force_ssl: true
|
|
24
|
-
// Enable HTTPS
|
|
25
|
-
})
|
|
26
|
-
});
|
|
27
|
-
const data = await response.json();
|
|
28
|
-
if (!response.ok) {
|
|
29
|
-
console.error(JSON.stringify(data));
|
|
30
|
-
throw new Error(`Failed to create site: ${data.message || "Unknown error"}`);
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
id: data.id,
|
|
34
|
-
name: data.name,
|
|
35
|
-
url: data.ssl_url || data.url,
|
|
36
|
-
adminUrl: data.admin_url
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
async function findNetlifySite({ token, name, scope }) {
|
|
40
|
-
const response = await fetch(`https://api.netlify.com/api/v1/${scope}/sites?filter=all&name=${name}`, {
|
|
41
|
-
headers: {
|
|
42
|
-
Authorization: `Bearer ${token}`,
|
|
43
|
-
"Content-Type": "application/json"
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const data = await response.json();
|
|
47
|
-
if (!response.ok || !Array.isArray(data)) {
|
|
48
|
-
throw new Error(`Failed to search sites: ${data.message || "Unknown error"}`);
|
|
49
|
-
}
|
|
50
|
-
return data.find((site) => site.name === name);
|
|
51
|
-
}
|
|
52
|
-
async function getOrCreateSite({ token, name, scope }) {
|
|
53
|
-
let existingSite;
|
|
54
|
-
try {
|
|
55
|
-
existingSite = await findNetlifySite({ token, name, scope });
|
|
56
|
-
} catch {
|
|
57
|
-
}
|
|
58
|
-
if (existingSite) {
|
|
59
|
-
return existingSite;
|
|
60
|
-
}
|
|
61
|
-
return createNetlifySite({ token, name, scope });
|
|
62
|
-
}
|
|
11
|
+
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
63
12
|
|
|
64
13
|
// src/index.ts
|
|
65
14
|
var NetlifyDeployer = class extends deployer.Deployer {
|
|
66
|
-
|
|
67
|
-
projectName;
|
|
68
|
-
token;
|
|
69
|
-
constructor({ scope, projectName, token }) {
|
|
15
|
+
constructor() {
|
|
70
16
|
super({ name: "NETLIFY" });
|
|
71
|
-
this.
|
|
72
|
-
this.projectName = projectName;
|
|
73
|
-
this.token = token;
|
|
17
|
+
this.outputDir = path.join(".netlify", "v1", "functions", "api");
|
|
74
18
|
}
|
|
75
|
-
|
|
76
|
-
if (!fs.existsSync(path.join(dir, "netlify/functions/api"))) {
|
|
77
|
-
fs.mkdirSync(path.join(dir, "netlify/functions/api"), { recursive: true });
|
|
78
|
-
}
|
|
79
|
-
fs.writeFileSync(
|
|
80
|
-
path.join(dir, "netlify.toml"),
|
|
81
|
-
`[functions]
|
|
82
|
-
node_bundler = "esbuild"
|
|
83
|
-
directory = "netlify/functions"
|
|
84
|
-
|
|
85
|
-
[[redirects]]
|
|
86
|
-
force = true
|
|
87
|
-
from = "/*"
|
|
88
|
-
status = 200
|
|
89
|
-
to = "/.netlify/functions/api/:splat"
|
|
90
|
-
`
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
async installDependencies(outputDirectory, rootDir = process.cwd()) {
|
|
19
|
+
async installDependencies(outputDirectory, rootDir = process__default.default.cwd()) {
|
|
94
20
|
const deps = new services.DepsService(rootDir);
|
|
95
21
|
deps.__setLogger(this.logger);
|
|
96
22
|
await deps.install({
|
|
@@ -102,103 +28,71 @@ to = "/.netlify/functions/api/:splat"
|
|
|
102
28
|
}
|
|
103
29
|
});
|
|
104
30
|
}
|
|
105
|
-
async deploy(
|
|
106
|
-
|
|
107
|
-
const p2 = execa.execa(
|
|
108
|
-
"npx",
|
|
109
|
-
[
|
|
110
|
-
"netlify-cli",
|
|
111
|
-
"deploy",
|
|
112
|
-
"--site",
|
|
113
|
-
site.id,
|
|
114
|
-
"--auth",
|
|
115
|
-
this.token,
|
|
116
|
-
"--dir",
|
|
117
|
-
".",
|
|
118
|
-
"--functions",
|
|
119
|
-
"./netlify/functions"
|
|
120
|
-
],
|
|
121
|
-
{
|
|
122
|
-
cwd: path.join(outputDirectory, this.outputDir)
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
p2.stdout.pipe(process.stdout);
|
|
126
|
-
await p2;
|
|
31
|
+
async deploy() {
|
|
32
|
+
this.logger?.info("Deploying to Netlify failed. Please use the Netlify dashboard to deploy.");
|
|
127
33
|
}
|
|
128
34
|
async prepare(outputDirectory) {
|
|
129
35
|
await super.prepare(outputDirectory);
|
|
130
|
-
this.writeFiles({ dir: path.join(outputDirectory, this.outputDir) });
|
|
131
36
|
}
|
|
132
|
-
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
133
|
-
|
|
37
|
+
async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
|
|
38
|
+
const result = await this._bundle(
|
|
134
39
|
this.getEntry(),
|
|
135
40
|
entryFile,
|
|
136
|
-
outputDirectory,
|
|
41
|
+
{ outputDirectory, projectRoot, enableEsmShim: true },
|
|
137
42
|
toolsPaths,
|
|
138
|
-
path.join(outputDirectory, this.outputDir
|
|
43
|
+
path.join(outputDirectory, this.outputDir)
|
|
139
44
|
);
|
|
45
|
+
await esm.writeJson(path.join(outputDirectory, ".netlify", "v1", "config.json"), {
|
|
46
|
+
functions: {
|
|
47
|
+
directory: ".netlify/v1/functions",
|
|
48
|
+
node_bundler: "none",
|
|
49
|
+
// Mastra pre-bundles, don't re-bundle
|
|
50
|
+
included_files: [".netlify/v1/functions/**"]
|
|
51
|
+
},
|
|
52
|
+
redirects: [
|
|
53
|
+
{
|
|
54
|
+
force: true,
|
|
55
|
+
from: "/*",
|
|
56
|
+
to: "/.netlify/functions/api/:splat",
|
|
57
|
+
status: 200
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
await esm.move(path.join(outputDirectory, ".netlify", "v1"), path.join(process__default.default.cwd(), ".netlify", "v1"), {
|
|
62
|
+
overwrite: true
|
|
63
|
+
});
|
|
64
|
+
return result;
|
|
140
65
|
}
|
|
141
66
|
getEntry() {
|
|
142
67
|
return `
|
|
143
68
|
import { handle } from 'hono/netlify'
|
|
144
69
|
import { mastra } from '#mastra';
|
|
145
|
-
import { createHonoServer } from '#server';
|
|
146
|
-
import {
|
|
147
|
-
import {
|
|
148
|
-
import { TABLE_EVALS } from '@mastra/core/storage';
|
|
149
|
-
import { checkEvalStorageFields } from '@mastra/core/utils';
|
|
150
|
-
|
|
151
|
-
registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
|
|
152
|
-
evaluate({
|
|
153
|
-
agentName,
|
|
154
|
-
input,
|
|
155
|
-
metric,
|
|
156
|
-
output,
|
|
157
|
-
runId,
|
|
158
|
-
globalRunId: runId,
|
|
159
|
-
instructions,
|
|
160
|
-
});
|
|
161
|
-
});
|
|
70
|
+
import { createHonoServer, getToolExports } from '#server';
|
|
71
|
+
import { tools } from '#tools';
|
|
72
|
+
import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';
|
|
162
73
|
|
|
163
74
|
if (mastra.getStorage()) {
|
|
164
|
-
|
|
165
|
-
mastra.getStorage().init();
|
|
75
|
+
mastra.__registerInternalWorkflow(scoreTracesWorkflow);
|
|
166
76
|
}
|
|
167
77
|
|
|
168
|
-
|
|
169
|
-
const storage = mastra.getStorage();
|
|
170
|
-
if (storage) {
|
|
171
|
-
// Check for required fields
|
|
172
|
-
const logger = mastra?.getLogger();
|
|
173
|
-
const areFieldsValid = checkEvalStorageFields(traceObject, logger);
|
|
174
|
-
if (!areFieldsValid) return;
|
|
175
|
-
|
|
176
|
-
await storage.insert({
|
|
177
|
-
tableName: TABLE_EVALS,
|
|
178
|
-
record: {
|
|
179
|
-
input: traceObject.input,
|
|
180
|
-
output: traceObject.output,
|
|
181
|
-
result: JSON.stringify(traceObject.result || {}),
|
|
182
|
-
agent_name: traceObject.agentName,
|
|
183
|
-
metric_name: traceObject.metricName,
|
|
184
|
-
instructions: traceObject.instructions,
|
|
185
|
-
test_info: null,
|
|
186
|
-
global_run_id: traceObject.globalRunId,
|
|
187
|
-
run_id: traceObject.runId,
|
|
188
|
-
created_at: new Date().toISOString(),
|
|
189
|
-
},
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
const app = await createHonoServer(mastra);
|
|
78
|
+
const app = await createHonoServer(mastra, { tools: getToolExports(tools) });
|
|
195
79
|
|
|
196
80
|
export default handle(app)
|
|
197
81
|
`;
|
|
198
82
|
}
|
|
199
83
|
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
200
84
|
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
85
|
+
const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
|
|
86
|
+
if (hasLibsql) {
|
|
87
|
+
this.logger?.error(
|
|
88
|
+
`Netlify Deployer does not support @libsql/client (which may have been installed by @mastra/libsql) as a dependency.
|
|
89
|
+
LibSQL with file URLs uses native Node.js bindings that cannot run in serverless environments. Use other Mastra Storage options instead.`
|
|
90
|
+
);
|
|
91
|
+
process__default.default.exit(1);
|
|
92
|
+
}
|
|
201
93
|
}
|
|
202
94
|
};
|
|
203
95
|
|
|
204
96
|
exports.NetlifyDeployer = NetlifyDeployer;
|
|
97
|
+
//# sourceMappingURL=index.cjs.map
|
|
98
|
+
//# 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;AACpC,IAAA,IAAA,CAAK,WAAA,CAAY,KAAK,MAAM,CAAA;AAE5B,IAAA,MAAM,KAAK,OAAA,CAAQ;AAAA,MACjB,GAAA,EAAKF,SAAA,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,CACJ,SAAA,EACA,iBACA,EAAE,UAAA,EAAY,aAAY,EACX;AACf,IAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,OAAA;AAAA,MACxB,KAAK,QAAA,EAAS;AAAA,MACd,SAAA;AAAA,MACA,EAAE,eAAA,EAAiB,WAAA,EAAa,aAAA,EAAe,IAAA,EAAK;AAAA,MACpD,UAAA;AAAA,MACAA,SAAA,CAAK,eAAA,EAAiB,IAAA,CAAK,SAAS;AAAA,KACtC;AAIA,IAAA,MAAMG,cAAUH,SAAA,CAAK,eAAA,EAAiB,UAAA,EAAY,IAAA,EAAM,aAAa,CAAA,EAAG;AAAA,MACtE,SAAA,EAAW;AAAA,QACT,SAAA,EAAW,uBAAA;AAAA,QACX,YAAA,EAAc,MAAA;AAAA;AAAA,QACd,cAAA,EAAgB,CAAC,0BAA0B;AAAA,OAC7C;AAAA,MACA,SAAA,EAAW;AAAA,QACT;AAAA,UACE,KAAA,EAAO,IAAA;AAAA,UACP,IAAA,EAAM,IAAA;AAAA,UACN,EAAA,EAAI,gCAAA;AAAA,UACJ,MAAA,EAAQ;AAAA;AACV;AACF,KACD,CAAA;AAED,IAAA,MAAMI,QAAA,CAAKJ,SAAA,CAAK,eAAA,EAAiB,UAAA,EAAY,IAAI,CAAA,EAAGA,SAAA,CAAKC,wBAAA,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,MAAAA,wBAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB;AAAA,EACF;AACF","file":"index.cjs","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/dist/index.d.ts
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
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, projectRoot }: {
|
|
8
|
+
toolsPaths: (string | string[])[];
|
|
9
|
+
projectRoot: string;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
private getEntry;
|
|
12
|
+
lint(entryFile: string, outputDirectory: string, toolsPaths: (string | string[])[]): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# 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,CACV,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE;QAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GACtF,OAAO,CAAC,IAAI,CAAC;IAkChB,OAAO,CAAC,QAAQ;IAkBV,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAczG"}
|