@mastra/deployer-cloudflare 0.0.1-alpha.34 → 0.0.1-alpha.5
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 +0 -243
- package/dist/deployer-cloudflare.cjs.development.js +458 -0
- package/dist/deployer-cloudflare.cjs.development.js.map +1 -0
- package/dist/deployer-cloudflare.cjs.production.min.js +2 -0
- package/dist/deployer-cloudflare.cjs.production.min.js.map +1 -0
- package/dist/deployer-cloudflare.esm.js +435 -0
- package/dist/deployer-cloudflare.esm.js.map +1 -0
- package/dist/index.d.ts +15 -26
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -148
- package/dist/secrets-manager/index.d.ts +2 -3
- package/dist/secrets-manager/index.d.ts.map +1 -0
- package/package.json +18 -17
- package/src/index.ts +35 -131
- package/src/secrets-manager/index.ts +3 -3
- package/tsconfig.json +7 -2
- package/vitest.config.ts +1 -1
- package/README.md +0 -99
- package/dist/secrets-manager/index.js +0 -87
- package/global.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -1,151 +1,8 @@
|
|
|
1
|
-
import { Deployer, createChildProcessLogger } from '@mastra/deployer';
|
|
2
|
-
import { getBundler } from '@mastra/deployer/build';
|
|
3
|
-
import virtual from '@rollup/plugin-virtual';
|
|
4
|
-
import { Cloudflare } from 'cloudflare';
|
|
5
|
-
import { writeFileSync } from 'fs';
|
|
6
|
-
import { join } from 'path';
|
|
7
1
|
|
|
8
|
-
|
|
9
|
-
var CloudflareDeployer = class extends Deployer {
|
|
10
|
-
cloudflare;
|
|
11
|
-
routes = [];
|
|
12
|
-
workerNamespace;
|
|
13
|
-
scope;
|
|
14
|
-
env;
|
|
15
|
-
projectName;
|
|
16
|
-
constructor({
|
|
17
|
-
scope,
|
|
18
|
-
env,
|
|
19
|
-
projectName = "mastra",
|
|
20
|
-
routes,
|
|
21
|
-
workerNamespace,
|
|
22
|
-
auth
|
|
23
|
-
}) {
|
|
24
|
-
super({ name: "CLOUDFLARE" });
|
|
25
|
-
this.scope = scope;
|
|
26
|
-
this.projectName = projectName;
|
|
27
|
-
this.routes = routes;
|
|
28
|
-
this.workerNamespace = workerNamespace;
|
|
29
|
-
if (env) {
|
|
30
|
-
this.env = env;
|
|
31
|
-
}
|
|
32
|
-
this.cloudflare = new Cloudflare(auth);
|
|
33
|
-
}
|
|
34
|
-
async writePackageJson(outputDirectory) {
|
|
35
|
-
this.logger.debug(`Writing package.json`);
|
|
36
|
-
const pkgPath = join(outputDirectory, "package.json");
|
|
37
|
-
writeFileSync(
|
|
38
|
-
pkgPath,
|
|
39
|
-
JSON.stringify(
|
|
40
|
-
{
|
|
41
|
-
name: "server",
|
|
42
|
-
version: "1.0.0",
|
|
43
|
-
description: "",
|
|
44
|
-
type: "module",
|
|
45
|
-
main: "index.mjs",
|
|
46
|
-
scripts: {
|
|
47
|
-
start: "node ./index.mjs",
|
|
48
|
-
build: 'echo "Already built"'
|
|
49
|
-
},
|
|
50
|
-
author: "Mastra",
|
|
51
|
-
license: "ISC",
|
|
52
|
-
dependencies: {
|
|
53
|
-
"@mastra/core": "latest"
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
null,
|
|
57
|
-
2
|
|
58
|
-
)
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
async writeFiles(outputDirectory) {
|
|
62
|
-
const env = await this.loadEnvVars();
|
|
63
|
-
const envsAsObject = Object.assign({}, Object.fromEntries(env.entries()), this.env);
|
|
64
|
-
const cfWorkerName = this.projectName;
|
|
65
|
-
const wranglerConfig = {
|
|
66
|
-
name: cfWorkerName,
|
|
67
|
-
main: "index.mjs",
|
|
68
|
-
compatibility_date: "2024-12-02",
|
|
69
|
-
compatibility_flags: ["nodejs_compat"],
|
|
70
|
-
observability: {
|
|
71
|
-
logs: {
|
|
72
|
-
enabled: true
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
vars: envsAsObject
|
|
76
|
-
};
|
|
77
|
-
if (!this.workerNamespace && this.routes) {
|
|
78
|
-
wranglerConfig.routes = this.routes;
|
|
79
|
-
}
|
|
80
|
-
writeFileSync(join(outputDirectory, "wrangler.json"), JSON.stringify(wranglerConfig));
|
|
81
|
-
}
|
|
82
|
-
getEntry() {
|
|
83
|
-
return `
|
|
84
|
-
export default {
|
|
85
|
-
fetch: async (request, env, context) => {
|
|
86
|
-
Object.keys(env).forEach(key => {
|
|
87
|
-
process.env[key] = env[key]
|
|
88
|
-
})
|
|
2
|
+
'use strict'
|
|
89
3
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
4
|
+
if (process.env.NODE_ENV === 'production') {
|
|
5
|
+
module.exports = require('./deployer-cloudflare.cjs.production.min.js')
|
|
6
|
+
} else {
|
|
7
|
+
module.exports = require('./deployer-cloudflare.cjs.development.js')
|
|
95
8
|
}
|
|
96
|
-
`;
|
|
97
|
-
}
|
|
98
|
-
async bundle(mastraDir, outputDirectory) {
|
|
99
|
-
const bundler = await getBundler(
|
|
100
|
-
{
|
|
101
|
-
input: "#entry",
|
|
102
|
-
plugins: [virtual({ "#entry": this.getEntry() })],
|
|
103
|
-
external: [/^@opentelemetry\//],
|
|
104
|
-
treeshake: "smallest"
|
|
105
|
-
},
|
|
106
|
-
{ platform: "browser" }
|
|
107
|
-
);
|
|
108
|
-
await bundler.write({
|
|
109
|
-
inlineDynamicImports: true,
|
|
110
|
-
file: join(outputDirectory, "index.mjs"),
|
|
111
|
-
format: "es"
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
async prepare(outputDirectory) {
|
|
115
|
-
await super.prepare(outputDirectory);
|
|
116
|
-
await this.writeFiles(outputDirectory);
|
|
117
|
-
}
|
|
118
|
-
async deploy(outputDirectory) {
|
|
119
|
-
const cmd = this.workerNamespace ? `npm exec -- wrangler deploy --dispatch-namespace ${this.workerNamespace}` : "npm exec -- wrangler deploy";
|
|
120
|
-
const cpLogger = createChildProcessLogger({
|
|
121
|
-
logger: this.logger,
|
|
122
|
-
root: outputDirectory
|
|
123
|
-
});
|
|
124
|
-
await cpLogger({
|
|
125
|
-
cmd,
|
|
126
|
-
args: [],
|
|
127
|
-
env: {
|
|
128
|
-
CLOUDFLARE_API_TOKEN: this.cloudflare.apiToken,
|
|
129
|
-
CLOUDFLARE_ACCOUNT_ID: this.scope,
|
|
130
|
-
...this.env,
|
|
131
|
-
PATH: process.env.PATH
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
async tagWorker({
|
|
136
|
-
workerName,
|
|
137
|
-
namespace,
|
|
138
|
-
tags,
|
|
139
|
-
scope
|
|
140
|
-
}) {
|
|
141
|
-
if (!this.cloudflare) {
|
|
142
|
-
throw new Error("Cloudflare Deployer not initialized");
|
|
143
|
-
}
|
|
144
|
-
await this.cloudflare.workersForPlatforms.dispatch.namespaces.scripts.tags.update(namespace, workerName, {
|
|
145
|
-
account_id: scope,
|
|
146
|
-
body: tags
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export { CloudflareDeployer };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare class CloudflareSecretsManager {
|
|
1
|
+
export declare class CloudflareSecretsManager {
|
|
2
2
|
accountId: string;
|
|
3
3
|
apiToken: string;
|
|
4
4
|
baseUrl: string;
|
|
@@ -22,5 +22,4 @@ declare class CloudflareSecretsManager {
|
|
|
22
22
|
}): Promise<any>;
|
|
23
23
|
listSecrets(workerId: string): Promise<any>;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
export { CloudflareSecretsManager };
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/secrets-manager/index.ts"],"names":[],"mappings":"AAAA,qBAAa,wBAAwB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;gBAEJ,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAMtE,YAAY,CAAC,EACjB,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;KACrB;IA6BK,oBAAoB,CAAC,EACzB,QAAQ,EACR,UAAU,EACV,OAAO,GACR,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACjC;IAOK,YAAY,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;IAwB/E,WAAW,CAAC,QAAQ,EAAE,MAAM;CAsBnC"}
|
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-cloudflare",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/deployer-cloudflare.esm.js",
|
|
7
8
|
"types": "dist/index.d.ts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/deployer-cloudflare.esm.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
16
19
|
},
|
|
17
20
|
"./package.json": "./package.json"
|
|
18
21
|
},
|
|
@@ -20,29 +23,27 @@
|
|
|
20
23
|
"author": "",
|
|
21
24
|
"license": "ISC",
|
|
22
25
|
"dependencies": {
|
|
23
|
-
"@rollup/plugin-virtual": "^3.0.2",
|
|
24
|
-
"cloudflare": "^4.0.0",
|
|
25
26
|
"date-fns": "^4.1.0",
|
|
26
27
|
"dotenv": "^16.3.1",
|
|
27
28
|
"execa": "^9.3.1",
|
|
28
|
-
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
29
|
-
"rollup-plugin-shim": "^1.0.0",
|
|
30
29
|
"wrangler": "^3.103.2",
|
|
31
30
|
"zod": "^3.24.1",
|
|
32
|
-
"@mastra/
|
|
33
|
-
"@mastra/
|
|
31
|
+
"@mastra/core": "0.1.27-alpha.67",
|
|
32
|
+
"@mastra/deployer": "0.0.1-alpha.4"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
35
|
"@babel/preset-env": "^7.26.0",
|
|
37
36
|
"@babel/preset-typescript": "^7.26.0",
|
|
38
37
|
"@tsconfig/recommended": "^1.0.7",
|
|
38
|
+
"@types/jsdom": "^21.1.7",
|
|
39
39
|
"@types/node": "^22.9.0",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
40
|
+
"@types/pg": "^8.11.10",
|
|
41
|
+
"dts-cli": "^2.0.5",
|
|
42
|
+
"vitest": "^2.1.8"
|
|
42
43
|
},
|
|
43
44
|
"scripts": {
|
|
44
|
-
"build": "
|
|
45
|
-
"dev": "
|
|
45
|
+
"build": "dts build",
|
|
46
|
+
"build:dev": "dts watch",
|
|
46
47
|
"test": "vitest run"
|
|
47
48
|
}
|
|
48
49
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import virtual from '@rollup/plugin-virtual';
|
|
4
|
-
import { Cloudflare } from 'cloudflare';
|
|
1
|
+
import { MastraDeployer } from '@mastra/core';
|
|
2
|
+
import * as child_process from 'child_process';
|
|
5
3
|
import { writeFileSync } from 'fs';
|
|
6
4
|
import { join } from 'path';
|
|
7
5
|
|
|
@@ -11,182 +9,88 @@ interface CFRoute {
|
|
|
11
9
|
custom_domain?: boolean;
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
export class CloudflareDeployer extends
|
|
15
|
-
private cloudflare: Cloudflare | undefined;
|
|
12
|
+
export class CloudflareDeployer extends MastraDeployer {
|
|
16
13
|
routes?: CFRoute[] = [];
|
|
17
14
|
workerNamespace?: string;
|
|
18
|
-
scope: string;
|
|
19
|
-
env?: Record<string, any>;
|
|
20
|
-
projectName?: string;
|
|
21
|
-
|
|
22
15
|
constructor({
|
|
23
16
|
scope,
|
|
24
17
|
env,
|
|
25
|
-
projectName
|
|
18
|
+
projectName,
|
|
26
19
|
routes,
|
|
27
20
|
workerNamespace,
|
|
28
|
-
auth,
|
|
29
21
|
}: {
|
|
30
22
|
env?: Record<string, any>;
|
|
31
23
|
scope: string;
|
|
32
|
-
projectName
|
|
24
|
+
projectName: string;
|
|
33
25
|
routes?: CFRoute[];
|
|
34
26
|
workerNamespace?: string;
|
|
35
|
-
auth: {
|
|
36
|
-
apiToken: string;
|
|
37
|
-
apiEmail?: string;
|
|
38
|
-
};
|
|
39
27
|
}) {
|
|
40
|
-
super({
|
|
28
|
+
super({ scope, env, projectName });
|
|
41
29
|
|
|
42
|
-
this.scope = scope;
|
|
43
|
-
this.projectName = projectName;
|
|
44
30
|
this.routes = routes;
|
|
45
31
|
this.workerNamespace = workerNamespace;
|
|
46
|
-
|
|
47
|
-
if (env) {
|
|
48
|
-
this.env = env;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
this.cloudflare = new Cloudflare(auth);
|
|
52
32
|
}
|
|
53
33
|
|
|
54
|
-
|
|
55
|
-
this.
|
|
56
|
-
const pkgPath = join(outputDirectory, 'package.json');
|
|
34
|
+
writeFiles({ dir }: { dir: string }): void {
|
|
35
|
+
this.loadEnvVars();
|
|
57
36
|
|
|
58
|
-
|
|
59
|
-
pkgPath,
|
|
60
|
-
JSON.stringify(
|
|
61
|
-
{
|
|
62
|
-
name: 'server',
|
|
63
|
-
version: '1.0.0',
|
|
64
|
-
description: '',
|
|
65
|
-
type: 'module',
|
|
66
|
-
main: 'index.mjs',
|
|
67
|
-
scripts: {
|
|
68
|
-
start: 'node ./index.mjs',
|
|
69
|
-
build: 'echo "Already built"',
|
|
70
|
-
},
|
|
71
|
-
author: 'Mastra',
|
|
72
|
-
license: 'ISC',
|
|
73
|
-
dependencies: {
|
|
74
|
-
'@mastra/core': 'latest',
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
null,
|
|
78
|
-
2,
|
|
79
|
-
),
|
|
80
|
-
);
|
|
81
|
-
}
|
|
37
|
+
this.writeIndex({ dir });
|
|
82
38
|
|
|
83
|
-
|
|
84
|
-
const env = await this.loadEnvVars();
|
|
85
|
-
|
|
86
|
-
const envsAsObject = Object.assign({}, Object.fromEntries(env.entries()), this.env);
|
|
87
|
-
|
|
88
|
-
const cfWorkerName = this.projectName;
|
|
39
|
+
const cfWorkerName = this.projectName || 'mastra';
|
|
89
40
|
|
|
90
41
|
const wranglerConfig: Record<string, any> = {
|
|
91
42
|
name: cfWorkerName,
|
|
92
43
|
main: 'index.mjs',
|
|
93
44
|
compatibility_date: '2024-12-02',
|
|
94
45
|
compatibility_flags: ['nodejs_compat'],
|
|
46
|
+
build: {
|
|
47
|
+
command: 'npm install',
|
|
48
|
+
},
|
|
95
49
|
observability: {
|
|
96
50
|
logs: {
|
|
97
51
|
enabled: true,
|
|
98
52
|
},
|
|
99
53
|
},
|
|
100
|
-
vars:
|
|
54
|
+
vars: this.env,
|
|
101
55
|
};
|
|
102
56
|
|
|
103
57
|
if (!this.workerNamespace && this.routes) {
|
|
104
58
|
wranglerConfig.routes = this.routes;
|
|
105
59
|
}
|
|
106
60
|
|
|
107
|
-
writeFileSync(join(
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
private getEntry(): string {
|
|
111
|
-
return `
|
|
112
|
-
export default {
|
|
113
|
-
fetch: async (request, env, context) => {
|
|
114
|
-
Object.keys(env).forEach(key => {
|
|
115
|
-
process.env[key] = env[key]
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
const { mastra } = await import('#mastra')
|
|
119
|
-
const { createHonoServer } = await import('#server')
|
|
120
|
-
const app = await createHonoServer(mastra)
|
|
121
|
-
return app.fetch(request, env, context);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
`;
|
|
61
|
+
writeFileSync(join(dir, 'wrangler.json'), JSON.stringify(wranglerConfig));
|
|
125
62
|
}
|
|
126
63
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
64
|
+
writeIndex({ dir }: { dir: string }): void {
|
|
65
|
+
writeFileSync(
|
|
66
|
+
join(dir, './index.mjs'),
|
|
67
|
+
`
|
|
68
|
+
export default {
|
|
69
|
+
fetch: async (request, env, context) => {
|
|
70
|
+
Object.keys(env).forEach(key => {
|
|
71
|
+
process.env[key] = env[key]
|
|
72
|
+
})
|
|
73
|
+
const { app } = await import('./hono.mjs');
|
|
74
|
+
return app.fetch(request, env, context);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`,
|
|
136
78
|
);
|
|
137
|
-
|
|
138
|
-
await bundler.write({
|
|
139
|
-
inlineDynamicImports: true,
|
|
140
|
-
file: join(outputDirectory, 'index.mjs'),
|
|
141
|
-
format: 'es',
|
|
142
|
-
});
|
|
143
79
|
}
|
|
144
80
|
|
|
145
|
-
async
|
|
146
|
-
await super.prepare(outputDirectory);
|
|
147
|
-
await this.writeFiles(outputDirectory);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async deploy(outputDirectory: string): Promise<void> {
|
|
81
|
+
async deploy({ dir, token }: { dir: string; token: string }): Promise<void> {
|
|
151
82
|
const cmd = this.workerNamespace
|
|
152
83
|
? `npm exec -- wrangler deploy --dispatch-namespace ${this.workerNamespace}`
|
|
153
84
|
: 'npm exec -- wrangler deploy';
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
root: outputDirectory,
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
await cpLogger({
|
|
161
|
-
cmd,
|
|
162
|
-
args: [],
|
|
85
|
+
child_process.execSync(cmd, {
|
|
86
|
+
cwd: dir,
|
|
87
|
+
stdio: 'inherit',
|
|
163
88
|
env: {
|
|
164
|
-
CLOUDFLARE_API_TOKEN:
|
|
89
|
+
CLOUDFLARE_API_TOKEN: token,
|
|
165
90
|
CLOUDFLARE_ACCOUNT_ID: this.scope,
|
|
166
91
|
...this.env,
|
|
167
|
-
PATH: process.env.PATH
|
|
92
|
+
PATH: process.env.PATH,
|
|
168
93
|
},
|
|
169
94
|
});
|
|
170
95
|
}
|
|
171
|
-
|
|
172
|
-
async tagWorker({
|
|
173
|
-
workerName,
|
|
174
|
-
namespace,
|
|
175
|
-
tags,
|
|
176
|
-
scope,
|
|
177
|
-
}: {
|
|
178
|
-
scope: string;
|
|
179
|
-
workerName: string;
|
|
180
|
-
namespace: string;
|
|
181
|
-
tags: string[];
|
|
182
|
-
}): Promise<void> {
|
|
183
|
-
if (!this.cloudflare) {
|
|
184
|
-
throw new Error('Cloudflare Deployer not initialized');
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
await this.cloudflare.workersForPlatforms.dispatch.namespaces.scripts.tags.update(namespace, workerName, {
|
|
188
|
-
account_id: scope,
|
|
189
|
-
body: tags,
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
96
|
}
|
|
@@ -33,7 +33,7 @@ export class CloudflareSecretsManager {
|
|
|
33
33
|
}),
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
const data =
|
|
36
|
+
const data = await response.json();
|
|
37
37
|
|
|
38
38
|
if (!data.success) {
|
|
39
39
|
throw new Error(data.errors[0].message);
|
|
@@ -72,7 +72,7 @@ export class CloudflareSecretsManager {
|
|
|
72
72
|
},
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
const data =
|
|
75
|
+
const data = await response.json();
|
|
76
76
|
|
|
77
77
|
if (!data.success) {
|
|
78
78
|
throw new Error(data.errors[0].message);
|
|
@@ -95,7 +95,7 @@ export class CloudflareSecretsManager {
|
|
|
95
95
|
},
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
const data =
|
|
98
|
+
const data = await response.json();
|
|
99
99
|
|
|
100
100
|
if (!data.success) {
|
|
101
101
|
throw new Error(data.errors[0].message);
|
package/tsconfig.json
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "../../tsconfig.
|
|
3
|
-
"
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"moduleResolution": "bundler",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"rootDir": "./src"
|
|
7
|
+
},
|
|
8
|
+
"include": ["src/**/*"],
|
|
4
9
|
"exclude": ["node_modules", "**/*.test.ts"]
|
|
5
10
|
}
|
package/vitest.config.ts
CHANGED
package/README.md
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
# @mastra/deployer-cloudflare
|
|
2
|
-
|
|
3
|
-
A Cloudflare Workers deployer for Mastra applications.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- Deploy Mastra applications to Cloudflare Workers
|
|
8
|
-
- Configure custom domains and routes
|
|
9
|
-
- Support for worker namespaces
|
|
10
|
-
- Automatic environment variable configuration
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
pnpm add @mastra/deployer-cloudflare
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
|
-
The Cloudflare deployer is used as part of the Mastra framework:
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { Mastra } from '@mastra/core';
|
|
24
|
-
import { CloudflareDeployer } from '@mastra/deployer-cloudflare';
|
|
25
|
-
|
|
26
|
-
const deployer = new CloudflareDeployer({
|
|
27
|
-
scope: 'your-account-id',
|
|
28
|
-
projectName: 'your-project-name',
|
|
29
|
-
routes: [
|
|
30
|
-
{
|
|
31
|
-
pattern: 'example.com/*',
|
|
32
|
-
zone_name: 'example.com',
|
|
33
|
-
custom_domain: true,
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
workerNamespace: 'your-namespace',
|
|
37
|
-
auth: {
|
|
38
|
-
apiToken: 'your-api-token',
|
|
39
|
-
apiEmail: 'your-email',
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const mastra = new Mastra({
|
|
44
|
-
deployer,
|
|
45
|
-
// ... other Mastra configuration options
|
|
46
|
-
});
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Configuration
|
|
50
|
-
|
|
51
|
-
### Constructor Options
|
|
52
|
-
|
|
53
|
-
- `scope` (required): Your Cloudflare account ID
|
|
54
|
-
- `projectName`: Name of your worker project
|
|
55
|
-
- `routes`: Array of route configurations for your worker
|
|
56
|
-
- `pattern`: URL pattern to match
|
|
57
|
-
- `zone_name`: Domain zone name
|
|
58
|
-
- `custom_domain`: Whether to use a custom domain
|
|
59
|
-
- `workerNamespace`: Namespace for your worker
|
|
60
|
-
- `auth`: Cloudflare authentication details
|
|
61
|
-
- `apiToken`: Your Cloudflare API token
|
|
62
|
-
- `apiEmail`: Your Cloudflare account email
|
|
63
|
-
|
|
64
|
-
## Environment Variables
|
|
65
|
-
|
|
66
|
-
The deployer will automatically load environment variables from:
|
|
67
|
-
|
|
68
|
-
- `.env` files in your project
|
|
69
|
-
- Environment variables passed through the Mastra configuration
|
|
70
|
-
|
|
71
|
-
## Routes
|
|
72
|
-
|
|
73
|
-
Routes can be configured to direct traffic to your worker based on URL patterns and domains:
|
|
74
|
-
|
|
75
|
-
```typescript
|
|
76
|
-
const routes = [
|
|
77
|
-
{
|
|
78
|
-
pattern: 'api.example.com/*',
|
|
79
|
-
zone_name: 'example.com',
|
|
80
|
-
custom_domain: true,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
pattern: 'example.com/api/*',
|
|
84
|
-
zone_name: 'example.com',
|
|
85
|
-
},
|
|
86
|
-
];
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Each route requires:
|
|
90
|
-
|
|
91
|
-
- `pattern`: URL pattern to match
|
|
92
|
-
- `zone_name`: Domain zone name
|
|
93
|
-
- `custom_domain`: (optional) Set to true to use a custom domain
|
|
94
|
-
|
|
95
|
-
## Requirements
|
|
96
|
-
|
|
97
|
-
- Cloudflare account with Workers enabled
|
|
98
|
-
- API token with appropriate permissions
|
|
99
|
-
- Domain(s) configured in Cloudflare (for custom domains)
|