@mastra/deployer-netlify 0.0.0-tsconfig-compile-20250703214351 → 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 +25 -45
- 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 +25 -45
- package/dist/index.js.map +1 -0
- package/package.json +32 -20
- package/dist/_tsup-dts-rollup.d.cts +0 -13
- package/dist/_tsup-dts-rollup.d.ts +0 -13
- 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
|
@@ -34,15 +34,21 @@ var NetlifyDeployer = class extends deployer.Deployer {
|
|
|
34
34
|
async prepare(outputDirectory) {
|
|
35
35
|
await super.prepare(outputDirectory);
|
|
36
36
|
}
|
|
37
|
-
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
37
|
+
async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
|
|
38
38
|
const result = await this._bundle(
|
|
39
39
|
this.getEntry(),
|
|
40
40
|
entryFile,
|
|
41
|
-
outputDirectory,
|
|
41
|
+
{ outputDirectory, projectRoot, enableEsmShim: true },
|
|
42
42
|
toolsPaths,
|
|
43
43
|
path.join(outputDirectory, this.outputDir)
|
|
44
44
|
);
|
|
45
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
|
+
},
|
|
46
52
|
redirects: [
|
|
47
53
|
{
|
|
48
54
|
force: true,
|
|
@@ -61,58 +67,32 @@ var NetlifyDeployer = class extends deployer.Deployer {
|
|
|
61
67
|
return `
|
|
62
68
|
import { handle } from 'hono/netlify'
|
|
63
69
|
import { mastra } from '#mastra';
|
|
64
|
-
import { createHonoServer } from '#server';
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
67
|
-
import { TABLE_EVALS } from '@mastra/core/storage';
|
|
68
|
-
import { checkEvalStorageFields } from '@mastra/core/utils';
|
|
70
|
+
import { createHonoServer, getToolExports } from '#server';
|
|
71
|
+
import { tools } from '#tools';
|
|
72
|
+
import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';
|
|
69
73
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
input,
|
|
74
|
-
metric,
|
|
75
|
-
output,
|
|
76
|
-
runId,
|
|
77
|
-
globalRunId: runId,
|
|
78
|
-
instructions,
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
83
|
-
const storage = mastra.getStorage();
|
|
84
|
-
if (storage) {
|
|
85
|
-
// Check for required fields
|
|
86
|
-
const logger = mastra.getLogger();
|
|
87
|
-
const areFieldsValid = checkEvalStorageFields(traceObject, logger);
|
|
88
|
-
if (!areFieldsValid) return;
|
|
89
|
-
|
|
90
|
-
await storage.insert({
|
|
91
|
-
tableName: TABLE_EVALS,
|
|
92
|
-
record: {
|
|
93
|
-
input: traceObject.input,
|
|
94
|
-
output: traceObject.output,
|
|
95
|
-
result: JSON.stringify(traceObject.result || {}),
|
|
96
|
-
agent_name: traceObject.agentName,
|
|
97
|
-
metric_name: traceObject.metricName,
|
|
98
|
-
instructions: traceObject.instructions,
|
|
99
|
-
test_info: null,
|
|
100
|
-
global_run_id: traceObject.globalRunId,
|
|
101
|
-
run_id: traceObject.runId,
|
|
102
|
-
created_at: new Date().toISOString(),
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
});
|
|
74
|
+
if (mastra.getStorage()) {
|
|
75
|
+
mastra.__registerInternalWorkflow(scoreTracesWorkflow);
|
|
76
|
+
}
|
|
107
77
|
|
|
108
|
-
const app = await createHonoServer(mastra);
|
|
78
|
+
const app = await createHonoServer(mastra, { tools: getToolExports(tools) });
|
|
109
79
|
|
|
110
80
|
export default handle(app)
|
|
111
81
|
`;
|
|
112
82
|
}
|
|
113
83
|
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
114
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
|
+
}
|
|
115
93
|
}
|
|
116
94
|
};
|
|
117
95
|
|
|
118
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,C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s","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"}
|
package/dist/index.js
CHANGED
|
@@ -28,15 +28,21 @@ var NetlifyDeployer = class extends Deployer {
|
|
|
28
28
|
async prepare(outputDirectory) {
|
|
29
29
|
await super.prepare(outputDirectory);
|
|
30
30
|
}
|
|
31
|
-
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
31
|
+
async bundle(entryFile, outputDirectory, { toolsPaths, projectRoot }) {
|
|
32
32
|
const result = await this._bundle(
|
|
33
33
|
this.getEntry(),
|
|
34
34
|
entryFile,
|
|
35
|
-
outputDirectory,
|
|
35
|
+
{ outputDirectory, projectRoot, enableEsmShim: true },
|
|
36
36
|
toolsPaths,
|
|
37
37
|
join(outputDirectory, this.outputDir)
|
|
38
38
|
);
|
|
39
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
|
+
},
|
|
40
46
|
redirects: [
|
|
41
47
|
{
|
|
42
48
|
force: true,
|
|
@@ -55,58 +61,32 @@ var NetlifyDeployer = class extends Deployer {
|
|
|
55
61
|
return `
|
|
56
62
|
import { handle } from 'hono/netlify'
|
|
57
63
|
import { mastra } from '#mastra';
|
|
58
|
-
import { createHonoServer } from '#server';
|
|
59
|
-
import {
|
|
60
|
-
import {
|
|
61
|
-
import { TABLE_EVALS } from '@mastra/core/storage';
|
|
62
|
-
import { checkEvalStorageFields } from '@mastra/core/utils';
|
|
64
|
+
import { createHonoServer, getToolExports } from '#server';
|
|
65
|
+
import { tools } from '#tools';
|
|
66
|
+
import { scoreTracesWorkflow } from '@mastra/core/evals/scoreTraces';
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
input,
|
|
68
|
-
metric,
|
|
69
|
-
output,
|
|
70
|
-
runId,
|
|
71
|
-
globalRunId: runId,
|
|
72
|
-
instructions,
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
77
|
-
const storage = mastra.getStorage();
|
|
78
|
-
if (storage) {
|
|
79
|
-
// Check for required fields
|
|
80
|
-
const logger = mastra.getLogger();
|
|
81
|
-
const areFieldsValid = checkEvalStorageFields(traceObject, logger);
|
|
82
|
-
if (!areFieldsValid) return;
|
|
83
|
-
|
|
84
|
-
await storage.insert({
|
|
85
|
-
tableName: TABLE_EVALS,
|
|
86
|
-
record: {
|
|
87
|
-
input: traceObject.input,
|
|
88
|
-
output: traceObject.output,
|
|
89
|
-
result: JSON.stringify(traceObject.result || {}),
|
|
90
|
-
agent_name: traceObject.agentName,
|
|
91
|
-
metric_name: traceObject.metricName,
|
|
92
|
-
instructions: traceObject.instructions,
|
|
93
|
-
test_info: null,
|
|
94
|
-
global_run_id: traceObject.globalRunId,
|
|
95
|
-
run_id: traceObject.runId,
|
|
96
|
-
created_at: new Date().toISOString(),
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
});
|
|
68
|
+
if (mastra.getStorage()) {
|
|
69
|
+
mastra.__registerInternalWorkflow(scoreTracesWorkflow);
|
|
70
|
+
}
|
|
101
71
|
|
|
102
|
-
const app = await createHonoServer(mastra);
|
|
72
|
+
const app = await createHonoServer(mastra, { tools: getToolExports(tools) });
|
|
103
73
|
|
|
104
74
|
export default handle(app)
|
|
105
75
|
`;
|
|
106
76
|
}
|
|
107
77
|
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
108
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
|
+
}
|
|
109
87
|
}
|
|
110
88
|
};
|
|
111
89
|
|
|
112
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,CAAQ,KAAI,EAAG;AACpF,IAAA,MAAM,IAAA,GAAO,IAAI,WAAA,CAAY,OAAO,CAAA;AACpC,I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AA,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-
|
|
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.
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
19
20
|
"default": "./dist/index.cjs"
|
|
20
21
|
}
|
|
21
22
|
},
|
|
@@ -23,32 +24,43 @@
|
|
|
23
24
|
},
|
|
24
25
|
"keywords": [],
|
|
25
26
|
"author": "",
|
|
26
|
-
"license": "
|
|
27
|
+
"license": "Apache-2.0",
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"execa": "^9.6.0",
|
|
31
|
-
"fs-extra": "^11.3.0",
|
|
32
|
-
"zod": "^3.25.67",
|
|
33
|
-
"@mastra/deployer": "0.0.0-tsconfig-compile-20250703214351"
|
|
29
|
+
"fs-extra": "^11.3.3",
|
|
30
|
+
"@mastra/deployer": "0.0.0-type-testing-20260120105120"
|
|
34
31
|
},
|
|
35
32
|
"devDependencies": {
|
|
36
|
-
"@microsoft/api-extractor": "^7.52.8",
|
|
37
33
|
"@types/fs-extra": "^11.0.4",
|
|
38
|
-
"@types/node": "
|
|
39
|
-
"
|
|
34
|
+
"@types/node": "22.13.17",
|
|
35
|
+
"@vitest/coverage-v8": "4.0.12",
|
|
36
|
+
"@vitest/ui": "4.0.12",
|
|
37
|
+
"eslint": "^9.37.0",
|
|
40
38
|
"tsup": "^8.5.0",
|
|
41
|
-
"typescript": "^5.
|
|
42
|
-
"vitest": "
|
|
43
|
-
"@internal/lint": "0.0.0-
|
|
44
|
-
"@
|
|
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"
|
|
45
53
|
},
|
|
46
54
|
"peerDependencies": {
|
|
47
|
-
"
|
|
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"
|
|
48
60
|
},
|
|
49
61
|
"scripts": {
|
|
50
|
-
"build": "tsup
|
|
51
|
-
"build:watch": "
|
|
62
|
+
"build": "tsup --silent --config tsup.config.ts",
|
|
63
|
+
"build:watch": "tsup --watch --silent --config tsup.config.ts",
|
|
52
64
|
"test": "vitest run",
|
|
53
65
|
"lint": "eslint ."
|
|
54
66
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Deployer } from '@mastra/deployer';
|
|
2
|
-
|
|
3
|
-
export declare class NetlifyDeployer extends Deployer {
|
|
4
|
-
constructor();
|
|
5
|
-
protected installDependencies(outputDirectory: string, rootDir?: string): Promise<void>;
|
|
6
|
-
deploy(): Promise<void>;
|
|
7
|
-
prepare(outputDirectory: string): Promise<void>;
|
|
8
|
-
bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
9
|
-
private getEntry;
|
|
10
|
-
lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { }
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Deployer } from '@mastra/deployer';
|
|
2
|
-
|
|
3
|
-
export declare class NetlifyDeployer extends Deployer {
|
|
4
|
-
constructor();
|
|
5
|
-
protected installDependencies(outputDirectory: string, rootDir?: string): Promise<void>;
|
|
6
|
-
deploy(): Promise<void>;
|
|
7
|
-
prepare(outputDirectory: string): Promise<void>;
|
|
8
|
-
bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
9
|
-
private getEntry;
|
|
10
|
-
lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { }
|
package/dist/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { NetlifyDeployer } from './_tsup-dts-rollup.cjs';
|