@vurb/core 3.8.2 → 3.8.3

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.
@@ -4,79 +4,79 @@
4
4
  */
5
5
  /** Generate `prisma/schema.prisma` */
6
6
  export function prismaSchema() {
7
- return `// Prisma Schema — Database-Driven MCP Server
8
- //
9
- // The @vurb/prisma-gen generator reads annotations
10
- // and auto-generates Presenters + ToolBuilders with:
11
- // - Field-level security (/// @vurb.hide)
12
- // - Tenant isolation
13
- // - OOM protection
14
-
15
- generator client {
16
- provider = "prisma-client-js"
17
- }
18
-
19
- generator vurb {
20
- provider = "@vurb/prisma-gen"
21
- }
22
-
23
- datasource db {
24
- provider = "postgresql"
25
- url = env("DATABASE_URL")
26
- }
27
-
28
- model User {
29
- id String @id @default(cuid())
30
- email String @unique
31
- name String
32
-
33
- /// @vurb.hide — Stripped by the Egress Firewall before reaching the LLM
34
- password String
35
-
36
- role String @default("USER")
37
- createdAt DateTime @default(now())
38
- updatedAt DateTime @updatedAt
39
-
40
- posts Post[]
41
- }
42
-
43
- model Post {
44
- id String @id @default(cuid())
45
- title String
46
- content String?
47
- published Boolean @default(false)
48
- createdAt DateTime @default(now())
49
-
50
- author User @relation(fields: [authorId], references: [id])
51
- authorId String
52
- }
7
+ return `// Prisma Schema — Database-Driven MCP Server
8
+ //
9
+ // The @vurb/prisma-gen generator reads annotations
10
+ // and auto-generates Presenters + ToolBuilders with:
11
+ // - Field-level security (/// @vurb.hide)
12
+ // - Tenant isolation
13
+ // - OOM protection
14
+
15
+ generator client {
16
+ provider = "prisma-client-js"
17
+ }
18
+
19
+ generator vurb {
20
+ provider = "@vurb/prisma-gen"
21
+ }
22
+
23
+ datasource db {
24
+ provider = "postgresql"
25
+ url = env("DATABASE_URL")
26
+ }
27
+
28
+ model User {
29
+ id String @id @default(cuid())
30
+ email String @unique
31
+ name String
32
+
33
+ /// @vurb.hide — Stripped by the Egress Firewall before reaching the LLM
34
+ password String
35
+
36
+ role String @default("USER")
37
+ createdAt DateTime @default(now())
38
+ updatedAt DateTime @updatedAt
39
+
40
+ posts Post[]
41
+ }
42
+
43
+ model Post {
44
+ id String @id @default(cuid())
45
+ title String
46
+ content String?
47
+ published Boolean @default(false)
48
+ createdAt DateTime @default(now())
49
+
50
+ author User @relation(fields: [authorId], references: [id])
51
+ authorId String
52
+ }
53
53
  `;
54
54
  }
55
55
  /** Generate `src/tools/db/users.ts` */
56
56
  export function dbUsersToolTs() {
57
- return `/**
58
- * Database Users Tool — Prisma-Driven CRUD (Fluent API)
59
- *
60
- * Demonstrates:
61
- * - f.query() with .withOptionalNumber() typed parameter
62
- * - .handle(input, ctx) — input.take is typed as number | undefined
63
- * - Implicit success() wrapping
64
- */
65
- import { f } from '../../vurb.js';
66
-
67
- export default f.query('db.list_users')
68
- .describe('List users from the database')
69
- .withOptionalNumber('take', 'Max results (1-50)')
70
- .handle(async (input, ctx) => {
71
- // TODO: Replace with your Prisma client
72
- // const users = await ctx.db.user.findMany({ take: input.take ?? 10 });
73
- // return users;
74
-
75
- return {
76
- hint: 'Connect your Prisma client in src/context.ts to enable database queries.',
77
- example: 'const users = await ctx.db.user.findMany({ take: 10 })',
78
- };
79
- });
57
+ return `/**
58
+ * Database Users Tool — Prisma-Driven CRUD (Fluent API)
59
+ *
60
+ * Demonstrates:
61
+ * - f.query() with .withOptionalNumber() typed parameter
62
+ * - .handle(input, ctx) — input.take is typed as number | undefined
63
+ * - Implicit success() wrapping
64
+ */
65
+ import { f } from '../../vurb.js';
66
+
67
+ export default f.query('db.list_users')
68
+ .describe('List users from the database')
69
+ .withOptionalNumber('take', 'Max results (1-50)')
70
+ .handle(async (input, ctx) => {
71
+ // TODO: Replace with your Prisma client
72
+ // const users = await ctx.db.user.findMany({ take: input.take ?? 10 });
73
+ // return users;
74
+
75
+ return {
76
+ hint: 'Connect your Prisma client in src/context.ts to enable database queries.',
77
+ example: 'const users = await ctx.db.user.findMany({ take: 10 })',
78
+ };
79
+ });
80
80
  `;
81
81
  }
82
82
  //# sourceMappingURL=database.js.map
@@ -4,73 +4,73 @@
4
4
  */
5
5
  /** Generate `src/auth.ts` — OAuth Device Flow setup */
6
6
  export function oauthSetupTs(config) {
7
- return `/**
8
- * OAuth Setup — Device Flow Authentication (RFC 8628)
9
- *
10
- * Pre-configured \`createAuthTool()\` with login, complete, status, logout actions.
11
- * The \`requireAuth()\` middleware protects any tool with one line.
12
- *
13
- * 1. Set CLIENT_ID and AUTH endpoints in .env
14
- * 2. Register the auth tool in server.ts
15
- * 3. Use \`requireAuth()\` on protected tools
16
- */
17
- import { createAuthTool, TokenManager } from '@vurb/oauth';
18
- import type { ToolRegistry } from '@vurb/core';
19
-
20
- export function registerAuth<TContext>(registry: ToolRegistry<TContext>): void {
21
- const clientId = process.env['OAUTH_CLIENT_ID'];
22
- const authEndpoint = process.env['OAUTH_AUTH_ENDPOINT'];
23
- const tokenEndpoint = process.env['OAUTH_TOKEN_ENDPOINT'];
24
-
25
- if (!clientId || !authEndpoint || !tokenEndpoint) {
26
- console.error('⚠️ OAUTH_CLIENT_ID, OAUTH_AUTH_ENDPOINT, OAUTH_TOKEN_ENDPOINT are required in .env');
27
- return;
28
- }
29
-
30
- const auth = createAuthTool({
31
- clientId,
32
- authorizationEndpoint: authEndpoint,
33
- tokenEndpoint,
34
- tokenManager: {
35
- configDir: '.${config.name}',
36
- envVar: '${config.name.toUpperCase().replace(/-/g, '_')}_TOKEN',
37
- },
38
- });
39
-
40
- registry.register(auth);
41
- console.error('🔐 OAuth Device Flow registered (auth.login → auth.complete → auth.status)');
42
- }
7
+ return `/**
8
+ * OAuth Setup — Device Flow Authentication (RFC 8628)
9
+ *
10
+ * Pre-configured \`createAuthTool()\` with login, complete, status, logout actions.
11
+ * The \`requireAuth()\` middleware protects any tool with one line.
12
+ *
13
+ * 1. Set CLIENT_ID and AUTH endpoints in .env
14
+ * 2. Register the auth tool in server.ts
15
+ * 3. Use \`requireAuth()\` on protected tools
16
+ */
17
+ import { createAuthTool, TokenManager } from '@vurb/oauth';
18
+ import type { ToolRegistry } from '@vurb/core';
19
+
20
+ export function registerAuth<TContext>(registry: ToolRegistry<TContext>): void {
21
+ const clientId = process.env['OAUTH_CLIENT_ID'];
22
+ const authEndpoint = process.env['OAUTH_AUTH_ENDPOINT'];
23
+ const tokenEndpoint = process.env['OAUTH_TOKEN_ENDPOINT'];
24
+
25
+ if (!clientId || !authEndpoint || !tokenEndpoint) {
26
+ console.error('⚠️ OAUTH_CLIENT_ID, OAUTH_AUTH_ENDPOINT, OAUTH_TOKEN_ENDPOINT are required in .env');
27
+ return;
28
+ }
29
+
30
+ const auth = createAuthTool({
31
+ clientId,
32
+ authorizationEndpoint: authEndpoint,
33
+ tokenEndpoint,
34
+ tokenManager: {
35
+ configDir: '.${config.name}',
36
+ envVar: '${config.name.toUpperCase().replace(/-/g, '_')}_TOKEN',
37
+ },
38
+ });
39
+
40
+ registry.register(auth);
41
+ console.error('🔐 OAuth Device Flow registered (auth.login → auth.complete → auth.status)');
42
+ }
43
43
  `;
44
44
  }
45
45
  /** Generate `src/middleware/auth.ts` — requireAuth middleware */
46
46
  export function oauthMiddlewareTs() {
47
- return `/**
48
- * Auth Middleware — Protect tools with requireAuth()
49
- *
50
- * @example
51
- * \`\`\`ts
52
- * import { withAuth } from '../middleware/auth.js';
53
- *
54
- * export default f.query('projects.list')
55
- * .describe('List all projects')
56
- * .use(withAuth)
57
- * .handle(async (input, ctx) => { /* authenticated */ });
58
- * \`\`\`
59
- */
60
- import { requireAuth } from '@vurb/oauth';
61
-
62
- /**
63
- * Pre-configured auth middleware.
64
- * Rejects unauthenticated requests with \`AUTH_REQUIRED\` + self-healing hints.
65
- */
66
- export const withAuth = requireAuth({
67
- extractToken: (ctx: unknown) => {
68
- const obj = ctx as Record<string, unknown>;
69
- return typeof obj['token'] === 'string' ? obj['token'] : null;
70
- },
71
- recoveryHint: 'Call auth action=login to authenticate via browser',
72
- recoveryAction: 'auth',
73
- });
47
+ return `/**
48
+ * Auth Middleware — Protect tools with requireAuth()
49
+ *
50
+ * @example
51
+ * \`\`\`ts
52
+ * import { withAuth } from '../middleware/auth.js';
53
+ *
54
+ * export default f.query('projects.list')
55
+ * .describe('List all projects')
56
+ * .use(withAuth)
57
+ * .handle(async (input, ctx) => { /* authenticated */ });
58
+ * \`\`\`
59
+ */
60
+ import { requireAuth } from '@vurb/oauth';
61
+
62
+ /**
63
+ * Pre-configured auth middleware.
64
+ * Rejects unauthenticated requests with \`AUTH_REQUIRED\` + self-healing hints.
65
+ */
66
+ export const withAuth = requireAuth({
67
+ extractToken: (ctx: unknown) => {
68
+ const obj = ctx as Record<string, unknown>;
69
+ return typeof obj['token'] === 'string' ? obj['token'] : null;
70
+ },
71
+ recoveryHint: 'Call auth action=login to authenticate via browser',
72
+ recoveryAction: 'auth',
73
+ });
74
74
  `;
75
75
  }
76
76
  //# sourceMappingURL=oauth.js.map
@@ -1,106 +1,106 @@
1
1
  /** Generate `openapi.yaml` — Sample OpenAPI spec */
2
2
  export function openapiYaml(config) {
3
- return `# OpenAPI 3.0 Specification — Sample
4
- #
5
- # Replace this with your actual API spec, then run:
6
- # npx @vurb/openapi-gen ./openapi.yaml --outDir ./src/generated
7
- #
8
- # The generator creates Presenters, Tools, Registry, and server
9
- # bootstrap — all configurable via YAML annotations.
10
-
11
- openapi: '3.0.3'
12
- info:
13
- title: '${config.name} API'
14
- version: '0.1.0'
15
- description: Sample API for Vurb OpenAPI generation
16
-
17
- servers:
18
- - url: http://localhost:3000/api
19
-
20
- paths:
21
- /health:
22
- get:
23
- operationId: getHealth
24
- summary: Health check endpoint
25
- responses:
26
- '200':
27
- description: Server health status
28
- content:
29
- application/json:
30
- schema:
31
- type: object
32
- properties:
33
- status:
34
- type: string
35
- example: healthy
36
- uptime:
37
- type: number
38
- example: 12345.67
39
-
40
- /users:
41
- get:
42
- operationId: listUsers
43
- summary: List all users
44
- parameters:
45
- - name: limit
46
- in: query
47
- schema:
48
- type: integer
49
- minimum: 1
50
- maximum: 100
51
- default: 10
52
- responses:
53
- '200':
54
- description: List of users
55
- content:
56
- application/json:
57
- schema:
58
- type: array
59
- items:
60
- $ref: '#/components/schemas/User'
61
-
62
- components:
63
- schemas:
64
- User:
65
- type: object
66
- properties:
67
- id:
68
- type: string
69
- name:
70
- type: string
71
- email:
72
- type: string
3
+ return `# OpenAPI 3.0 Specification — Sample
4
+ #
5
+ # Replace this with your actual API spec, then run:
6
+ # npx @vurb/openapi-gen ./openapi.yaml --outDir ./src/generated
7
+ #
8
+ # The generator creates Presenters, Tools, Registry, and server
9
+ # bootstrap — all configurable via YAML annotations.
10
+
11
+ openapi: '3.0.3'
12
+ info:
13
+ title: '${config.name} API'
14
+ version: '0.1.0'
15
+ description: Sample API for Vurb OpenAPI generation
16
+
17
+ servers:
18
+ - url: http://localhost:3000/api
19
+
20
+ paths:
21
+ /health:
22
+ get:
23
+ operationId: getHealth
24
+ summary: Health check endpoint
25
+ responses:
26
+ '200':
27
+ description: Server health status
28
+ content:
29
+ application/json:
30
+ schema:
31
+ type: object
32
+ properties:
33
+ status:
34
+ type: string
35
+ example: healthy
36
+ uptime:
37
+ type: number
38
+ example: 12345.67
39
+
40
+ /users:
41
+ get:
42
+ operationId: listUsers
43
+ summary: List all users
44
+ parameters:
45
+ - name: limit
46
+ in: query
47
+ schema:
48
+ type: integer
49
+ minimum: 1
50
+ maximum: 100
51
+ default: 10
52
+ responses:
53
+ '200':
54
+ description: List of users
55
+ content:
56
+ application/json:
57
+ schema:
58
+ type: array
59
+ items:
60
+ $ref: '#/components/schemas/User'
61
+
62
+ components:
63
+ schemas:
64
+ User:
65
+ type: object
66
+ properties:
67
+ id:
68
+ type: string
69
+ name:
70
+ type: string
71
+ email:
72
+ type: string
73
73
  `;
74
74
  }
75
75
  /** Generate `SETUP.md` — OpenAPI generation instructions */
76
76
  export function openapiSetupMd() {
77
- return `# OpenAPI Generator Setup
78
-
79
- This project is configured for the **Legacy API Proxy** ingestion vector.
80
-
81
- ## Steps
82
-
83
- 1. Replace \`openapi.yaml\` with your actual OpenAPI 3.x spec
84
-
85
- 2. Generate the MCP server from the spec:
86
- \`\`\`bash
87
- npx @vurb/openapi-gen ./openapi.yaml --outDir ./src/generated
88
- \`\`\`
89
-
90
- 3. The generator creates:
91
- - Presenters with Zod schemas (Egress Firewall)
92
- - Tool builders with typed handlers
93
- - Registry setup with all endpoints
94
-
95
- 4. Import and register in \`src/server.ts\`:
96
- \`\`\`typescript
97
- import { generatedTools } from './generated/registry.js';
98
- registry.registerAll(...generatedTools);
99
- \`\`\`
100
-
101
- ## Documentation
102
-
103
- See: [OpenAPI Generator](https://vurb.vinkius.com/openapi-gen)
77
+ return `# OpenAPI Generator Setup
78
+
79
+ This project is configured for the **Legacy API Proxy** ingestion vector.
80
+
81
+ ## Steps
82
+
83
+ 1. Replace \`openapi.yaml\` with your actual OpenAPI 3.x spec
84
+
85
+ 2. Generate the MCP server from the spec:
86
+ \`\`\`bash
87
+ npx @vurb/openapi-gen ./openapi.yaml --outDir ./src/generated
88
+ \`\`\`
89
+
90
+ 3. The generator creates:
91
+ - Presenters with Zod schemas (Egress Firewall)
92
+ - Tool builders with typed handlers
93
+ - Registry setup with all endpoints
94
+
95
+ 4. Import and register in \`src/server.ts\`:
96
+ \`\`\`typescript
97
+ import { generatedTools } from './generated/registry.js';
98
+ registry.registerAll(...generatedTools);
99
+ \`\`\`
100
+
101
+ ## Documentation
102
+
103
+ See: [OpenAPI Generator](https://vurb.vinkius.com/openapi-gen)
104
104
  `;
105
105
  }
106
106
  //# sourceMappingURL=openapi.js.map