@mastra/vercel 1.0.0
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/package.json +63 -0
- package/src/Vercel.test.ts +61 -0
- package/src/assets/vercel.png +0 -0
- package/src/index.ts +67 -0
- package/src/openapi-components.ts +4184 -0
- package/src/openapi-paths.ts +52314 -0
- package/src/openapi.ts +28072 -0
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mastra/vercel",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/mylib.esm.js",
|
|
7
|
+
"typings": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"husky": {
|
|
13
|
+
"hooks": {
|
|
14
|
+
"pre-commit": "dts lint"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20 <22"
|
|
19
|
+
},
|
|
20
|
+
"size-limit": [
|
|
21
|
+
{
|
|
22
|
+
"path": "dist/mylib.cjs.production.min.js",
|
|
23
|
+
"limit": "10 KB"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"path": "dist/mylib.esm.js",
|
|
27
|
+
"limit": "10 KB"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@jest/globals": "^29.7.0",
|
|
32
|
+
"@rollup/plugin-image": "^3.0.3",
|
|
33
|
+
"@size-limit/preset-small-lib": "^11.1.4",
|
|
34
|
+
"@tsconfig/recommended": "^1.0.7",
|
|
35
|
+
"@types/jest": "^29.5.12",
|
|
36
|
+
"@types/lodash": "^4.17.7",
|
|
37
|
+
"@types/node": "^22.1.0",
|
|
38
|
+
"dts-cli": "^2.0.5",
|
|
39
|
+
"husky": "^9.1.4",
|
|
40
|
+
"jest": "^29.7.0",
|
|
41
|
+
"size-limit": "^11.1.4",
|
|
42
|
+
"ts-jest": "^29.2.4",
|
|
43
|
+
"tslib": "^2.6.3",
|
|
44
|
+
"typescript": "^5.5.4"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [],
|
|
47
|
+
"author": "",
|
|
48
|
+
"license": "ISC",
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"fets": "*",
|
|
51
|
+
"zod": "^3.23.8",
|
|
52
|
+
"@mastra/core": "0.1.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"analyze": "size-limit --why",
|
|
56
|
+
"build": "dts build",
|
|
57
|
+
"build:dev": "dts watch",
|
|
58
|
+
"lint": "dts lint",
|
|
59
|
+
"size": "size-limit",
|
|
60
|
+
"start": "dts watch",
|
|
61
|
+
"test": "jest"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
describe,
|
|
3
|
+
it,
|
|
4
|
+
beforeAll,
|
|
5
|
+
afterAll, //expect
|
|
6
|
+
} from '@jest/globals';
|
|
7
|
+
import { Framework } from '@mastra/core';
|
|
8
|
+
|
|
9
|
+
import { VercelIntegration } from '.';
|
|
10
|
+
|
|
11
|
+
const TOKEN = process.env.TOKEN!;
|
|
12
|
+
const dbUri = process.env.DB_URL!;
|
|
13
|
+
const connectionId = process.env.CONNECTION_ID!;
|
|
14
|
+
|
|
15
|
+
const integrationName = 'VERCEL';
|
|
16
|
+
|
|
17
|
+
const integrationFramework = Framework.init({
|
|
18
|
+
name: 'TestFramework',
|
|
19
|
+
integrations: [new VercelIntegration()],
|
|
20
|
+
workflows: {
|
|
21
|
+
systemApis: [],
|
|
22
|
+
blueprintDirPath: '',
|
|
23
|
+
systemEvents: {},
|
|
24
|
+
},
|
|
25
|
+
db: {
|
|
26
|
+
provider: 'postgres',
|
|
27
|
+
uri: dbUri,
|
|
28
|
+
},
|
|
29
|
+
systemHostURL: 'http://localhost:3000',
|
|
30
|
+
routeRegistrationPath: '/api/mastra',
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
//const integration = integrationFramework.getIntegration(integrationName) as VercelIntegration
|
|
34
|
+
|
|
35
|
+
describe('vercel', () => {
|
|
36
|
+
beforeAll(async () => {
|
|
37
|
+
await integrationFramework.connectIntegrationByCredential({
|
|
38
|
+
name: integrationName,
|
|
39
|
+
connectionId,
|
|
40
|
+
credential: {
|
|
41
|
+
value: {
|
|
42
|
+
TOKEN,
|
|
43
|
+
},
|
|
44
|
+
type: 'API_KEY',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should 200 on some apis', async () => {
|
|
50
|
+
//const client = await integration.getApiClient({ connectionId });
|
|
51
|
+
//const response = await client['/2010-04-01/Accounts.json'].get();
|
|
52
|
+
//expect(response.status).toBe(200);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
afterAll(async () => {
|
|
56
|
+
await integrationFramework.disconnectIntegration({
|
|
57
|
+
name: integrationName,
|
|
58
|
+
connectionId,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
Binary file
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Integration, OpenAPI, IntegrationCredentialType, IntegrationAuth } from '@mastra/core';
|
|
2
|
+
import { createClient, type OASClient, type NormalizeOAS } from 'fets';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import VercelLogo from './assets/vercel.png';
|
|
7
|
+
import { openapi } from './openapi';
|
|
8
|
+
import { components } from './openapi-components';
|
|
9
|
+
import { paths } from './openapi-paths';
|
|
10
|
+
|
|
11
|
+
export class VercelIntegration extends Integration {
|
|
12
|
+
constructor() {
|
|
13
|
+
super({
|
|
14
|
+
authType: IntegrationCredentialType.API_KEY,
|
|
15
|
+
name: 'VERCEL',
|
|
16
|
+
logoUrl: VercelLogo,
|
|
17
|
+
authConnectionOptions: z.object({
|
|
18
|
+
TOKEN: z.string(),
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
getOpenApiSpec() {
|
|
24
|
+
return { paths, components } as unknown as OpenAPI;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getApiClient = async ({ connectionId }: { connectionId: string }): Promise<OASClient<NormalizeOAS<openapi>>> => {
|
|
28
|
+
const connection = await this.dataLayer?.getConnection({ name: this.name, connectionId });
|
|
29
|
+
|
|
30
|
+
if (!connection) {
|
|
31
|
+
throw new Error(`Connection not found for connectionId: ${connectionId}`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const credential = await this.dataLayer?.getCredentialsByConnection(connection.id);
|
|
35
|
+
const value = credential?.value as Record<string, string>;
|
|
36
|
+
|
|
37
|
+
const client = createClient<NormalizeOAS<openapi>>({
|
|
38
|
+
endpoint: `https://api.vercel.com`,
|
|
39
|
+
globalParams: {
|
|
40
|
+
headers: {
|
|
41
|
+
Authorization: `Bearer ${value?.['TOKEN']}`,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return client as any;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
registerEvents() {
|
|
50
|
+
this.events = {};
|
|
51
|
+
return this.events;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getAuthenticator() {
|
|
55
|
+
return new IntegrationAuth({
|
|
56
|
+
dataAccess: this.dataLayer!,
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
onConnectionCreated: () => {
|
|
59
|
+
// TODO
|
|
60
|
+
},
|
|
61
|
+
config: {
|
|
62
|
+
INTEGRATION_NAME: this.name,
|
|
63
|
+
AUTH_TYPE: this.config.authType,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|