@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.
@@ -85,47 +85,47 @@ export function tsconfig() {
85
85
  }
86
86
  /** Generate `.gitignore` */
87
87
  export function gitignore() {
88
- return `node_modules/
89
- dist/
90
- *.tsbuildinfo
91
- .env
92
- .env.local
93
- coverage/
88
+ return `node_modules/
89
+ dist/
90
+ *.tsbuildinfo
91
+ .env
92
+ .env.local
93
+ coverage/
94
94
  `;
95
95
  }
96
96
  /** Generate `.env.example` with vector-specific vars */
97
97
  export function envExample(config) {
98
- let env = `# ── Vurb Server Environment ─────────────────────
99
- # Copy this to .env and fill in your values.
100
-
101
- # Server
102
- NODE_ENV=development
98
+ let env = `# ── Vurb Server Environment ─────────────────────
99
+ # Copy this to .env and fill in your values.
100
+
101
+ # Server
102
+ NODE_ENV=development
103
103
  `;
104
104
  if (config.vector === 'prisma') {
105
- env += `
106
- # Database (Prisma)
107
- DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
105
+ env += `
106
+ # Database (Prisma)
107
+ DATABASE_URL="postgresql://user:password@localhost:5432/mydb?schema=public"
108
108
  `;
109
109
  }
110
110
  if (config.vector === 'n8n') {
111
- env += `
112
- # n8n Workflow Automation
113
- N8N_BASE_URL=http://localhost:5678
114
- N8N_API_KEY=your-api-key-here
111
+ env += `
112
+ # n8n Workflow Automation
113
+ N8N_BASE_URL=http://localhost:5678
114
+ N8N_API_KEY=your-api-key-here
115
115
  `;
116
116
  }
117
117
  if (config.vector === 'oauth') {
118
- env += `
119
- # OAuth Device Flow (RFC 8628)
120
- OAUTH_CLIENT_ID=your-client-id
121
- OAUTH_AUTH_ENDPOINT=https://api.example.com/oauth/device/code
122
- OAUTH_TOKEN_ENDPOINT=https://api.example.com/oauth/device/token
118
+ env += `
119
+ # OAuth Device Flow (RFC 8628)
120
+ OAUTH_CLIENT_ID=your-client-id
121
+ OAUTH_AUTH_ENDPOINT=https://api.example.com/oauth/device/code
122
+ OAUTH_TOKEN_ENDPOINT=https://api.example.com/oauth/device/token
123
123
  `;
124
124
  }
125
125
  if (config.transport === 'sse') {
126
- env += `
127
- # Streamable HTTP Transport
128
- PORT=3001
126
+ env += `
127
+ # Streamable HTTP Transport
128
+ PORT=3001
129
129
  `;
130
130
  }
131
131
  return env;
@@ -1,113 +1,113 @@
1
1
  /** Generate `src/vurb.ts` — The one-file context center */
2
2
  export function vurbTs() {
3
- return `/**
4
- * Vurb Instance — Context Initialization
5
- *
6
- * Define your context type ONCE. Every f.query(), f.mutation(),
7
- * f.presenter(), f.prompt(), and f.middleware() call inherits
8
- * AppContext — zero generic repetition anywhere in the codebase.
9
- */
10
- import { initVurb } from '@vurb/core';
11
- import type { AppContext } from './context.js';
12
-
13
- export const f = initVurb<AppContext>();
3
+ return `/**
4
+ * Vurb Instance — Context Initialization
5
+ *
6
+ * Define your context type ONCE. Every f.query(), f.mutation(),
7
+ * f.presenter(), f.prompt(), and f.middleware() call inherits
8
+ * AppContext — zero generic repetition anywhere in the codebase.
9
+ */
10
+ import { initVurb } from '@vurb/core';
11
+ import type { AppContext } from './context.js';
12
+
13
+ export const f = initVurb<AppContext>();
14
14
  `;
15
15
  }
16
16
  /** Generate `src/context.ts` — Application context type + factory */
17
17
  export function contextTs() {
18
- return `/**
19
- * Application Context — Shared State for Every Tool Handler
20
- *
21
- * Every f.query() / f.mutation() handler receives (input, ctx)
22
- * where ctx is this AppContext. Extend it with your own services
23
- * (DB client, auth, external APIs, etc.)
24
- */
25
-
26
- export interface AppContext {
27
- /** Current user role for RBAC checks */
28
- role: 'ADMIN' | 'USER' | 'GUEST';
29
-
30
- /** Tenant identifier (multi-tenancy) */
31
- tenantId: string;
32
- }
33
-
34
- /**
35
- * Create the application context for each tool invocation.
36
- *
37
- * In production, hydrate this from the MCP session metadata,
38
- * JWT tokens, or environment variables.
39
- */
40
- export function createContext(): AppContext {
41
- return {
42
- role: 'ADMIN',
43
- tenantId: 'default',
44
- };
45
- }
18
+ return `/**
19
+ * Application Context — Shared State for Every Tool Handler
20
+ *
21
+ * Every f.query() / f.mutation() handler receives (input, ctx)
22
+ * where ctx is this AppContext. Extend it with your own services
23
+ * (DB client, auth, external APIs, etc.)
24
+ */
25
+
26
+ export interface AppContext {
27
+ /** Current user role for RBAC checks */
28
+ role: 'ADMIN' | 'USER' | 'GUEST';
29
+
30
+ /** Tenant identifier (multi-tenancy) */
31
+ tenantId: string;
32
+ }
33
+
34
+ /**
35
+ * Create the application context for each tool invocation.
36
+ *
37
+ * In production, hydrate this from the MCP session metadata,
38
+ * JWT tokens, or environment variables.
39
+ */
40
+ export function createContext(): AppContext {
41
+ return {
42
+ role: 'ADMIN',
43
+ tenantId: 'default',
44
+ };
45
+ }
46
46
  `;
47
47
  }
48
48
  /** Generate `src/server.ts` — Bootstrap with autoDiscover + transport */
49
49
  export function serverTs(config) {
50
50
  if (config.transport === 'stdio') {
51
51
  // Simplified: one-liner bootstrap via startServer()
52
- return `/**
53
- * Server Bootstrap — Vurb
54
- *
55
- * Tools are auto-discovered from src/tools/.
56
- * Drop a file, it becomes a tool.
57
- */
58
- import { fileURLToPath } from 'node:url';
59
- import { autoDiscover, PromptRegistry, startServer } from '@vurb/core';
60
- import { createContext } from './context.js';
61
- import { f } from './vurb.js';
62
- import { GreetPrompt } from './prompts/greet.js';
63
-
64
- // ── Registry ─────────────────────────────────────────────
65
- const registry = f.registry();
66
- const prompts = new PromptRegistry();
67
-
68
- // ── Auto-Discover & Register ─────────────────────────────
69
- await autoDiscover(registry, fileURLToPath(new URL('./tools', import.meta.url)));
70
- prompts.register(GreetPrompt);
71
-
72
- // ── Start ────────────────────────────────────────────────
73
- await startServer({
74
- name: '${config.name}',
75
- registry,
76
- prompts,
77
- contextFactory: () => createContext(),
78
- });
52
+ return `/**
53
+ * Server Bootstrap — Vurb
54
+ *
55
+ * Tools are auto-discovered from src/tools/.
56
+ * Drop a file, it becomes a tool.
57
+ */
58
+ import { fileURLToPath } from 'node:url';
59
+ import { autoDiscover, PromptRegistry, startServer } from '@vurb/core';
60
+ import { createContext } from './context.js';
61
+ import { f } from './vurb.js';
62
+ import { GreetPrompt } from './prompts/greet.js';
63
+
64
+ // ── Registry ─────────────────────────────────────────────
65
+ const registry = f.registry();
66
+ const prompts = new PromptRegistry();
67
+
68
+ // ── Auto-Discover & Register ─────────────────────────────
69
+ await autoDiscover(registry, fileURLToPath(new URL('./tools', import.meta.url)));
70
+ prompts.register(GreetPrompt);
71
+
72
+ // ── Start ────────────────────────────────────────────────
73
+ await startServer({
74
+ name: '${config.name}',
75
+ registry,
76
+ prompts,
77
+ contextFactory: () => createContext(),
78
+ });
79
79
  `;
80
80
  }
81
81
  // Streamable HTTP transport — startServer handles all HTTP plumbing
82
- return `/**
83
- * Server Bootstrap — Vurb with Streamable HTTP Transport
84
- *
85
- * Tools are auto-discovered from src/tools/.
86
- * Drop a file, it becomes a tool.
87
- */
88
- import { fileURLToPath } from 'node:url';
89
- import { autoDiscover, PromptRegistry, startServer } from '@vurb/core';
90
- import { createContext } from './context.js';
91
- import { f } from './vurb.js';
92
- import { GreetPrompt } from './prompts/greet.js';
93
-
94
- // ── Registry ─────────────────────────────────────────────
95
- const registry = f.registry();
96
- const prompts = new PromptRegistry();
97
-
98
- // ── Auto-Discover & Register ─────────────────────────────
99
- await autoDiscover(registry, fileURLToPath(new URL('./tools', import.meta.url)));
100
- prompts.register(GreetPrompt);
101
-
102
- // ── Start ────────────────────────────────────────────────
103
- await startServer({
104
- name: '${config.name}',
105
- registry,
106
- prompts,
107
- contextFactory: () => createContext(),
108
- transport: 'http',
109
- port: Number(process.env['PORT'] ?? 3001),
110
- });
82
+ return `/**
83
+ * Server Bootstrap — Vurb with Streamable HTTP Transport
84
+ *
85
+ * Tools are auto-discovered from src/tools/.
86
+ * Drop a file, it becomes a tool.
87
+ */
88
+ import { fileURLToPath } from 'node:url';
89
+ import { autoDiscover, PromptRegistry, startServer } from '@vurb/core';
90
+ import { createContext } from './context.js';
91
+ import { f } from './vurb.js';
92
+ import { GreetPrompt } from './prompts/greet.js';
93
+
94
+ // ── Registry ─────────────────────────────────────────────
95
+ const registry = f.registry();
96
+ const prompts = new PromptRegistry();
97
+
98
+ // ── Auto-Discover & Register ─────────────────────────────
99
+ await autoDiscover(registry, fileURLToPath(new URL('./tools', import.meta.url)));
100
+ prompts.register(GreetPrompt);
101
+
102
+ // ── Start ────────────────────────────────────────────────
103
+ await startServer({
104
+ name: '${config.name}',
105
+ registry,
106
+ prompts,
107
+ contextFactory: () => createContext(),
108
+ transport: 'http',
109
+ port: Number(process.env['PORT'] ?? 3001),
110
+ });
111
111
  `;
112
112
  }
113
113
  //# sourceMappingURL=core.js.map
@@ -4,31 +4,31 @@
4
4
  */
5
5
  /** Generate `src/middleware/auth.ts` — RBAC middleware */
6
6
  export function authMiddlewareTs() {
7
- return `/**
8
- * Auth Middleware — RBAC Guard (Fluent API)
9
- *
10
- * Demonstrates f.middleware() — tRPC-style context derivation.
11
- * Rejects GUEST requests with a structured error.
12
- *
13
- * Usage in tools:
14
- * f.query('users.list')
15
- * .use(withAuth)
16
- * .handle(async (input, ctx) => {
17
- * // ctx now has ctx.role guaranteed non-GUEST
18
- * });
19
- *
20
- * In production, replace with JWT validation,
21
- * API key checks, or OAuth token verification.
22
- */
23
- import { f } from '../vurb.js';
24
- import { error } from '@vurb/core';
25
-
26
- export const withAuth = f.middleware(async (ctx) => {
27
- if (ctx.role === 'GUEST') {
28
- throw error('Access denied. Authentication required.');
29
- }
30
- return { verified: true as const };
31
- });
7
+ return `/**
8
+ * Auth Middleware — RBAC Guard (Fluent API)
9
+ *
10
+ * Demonstrates f.middleware() — tRPC-style context derivation.
11
+ * Rejects GUEST requests with a structured error.
12
+ *
13
+ * Usage in tools:
14
+ * f.query('users.list')
15
+ * .use(withAuth)
16
+ * .handle(async (input, ctx) => {
17
+ * // ctx now has ctx.role guaranteed non-GUEST
18
+ * });
19
+ *
20
+ * In production, replace with JWT validation,
21
+ * API key checks, or OAuth token verification.
22
+ */
23
+ import { f } from '../vurb.js';
24
+ import { error } from '@vurb/core';
25
+
26
+ export const withAuth = f.middleware(async (ctx) => {
27
+ if (ctx.role === 'GUEST') {
28
+ throw error('Access denied. Authentication required.');
29
+ }
30
+ return { verified: true as const };
31
+ });
32
32
  `;
33
33
  }
34
34
  //# sourceMappingURL=middleware.js.map
@@ -4,28 +4,28 @@
4
4
  */
5
5
  /** Generate `src/models/SystemModel.ts` */
6
6
  export function systemModelTs() {
7
- return `/**
8
- * System Model — MVA Domain Layer (defineModel)
9
- *
10
- * Defines the shape of system health data using defineModel().
11
- * The Model provides:
12
- * - Field types with m.string(), m.number(), etc.
13
- * - .describe() annotations that become JIT system rules
14
- * - Validation and casting for the domain entity
15
- *
16
- * The Presenter references this Model instead of raw z.object(),
17
- * keeping a single source of truth for the data shape.
18
- */
19
- import { defineModel } from '@vurb/core';
20
-
21
- export const SystemModel = defineModel('SystemHealth', m => {
22
- m.casts({
23
- status: m.string('Server operational status'),
24
- uptime: m.number('Uptime in seconds since process start'),
25
- version: m.string('Server version string'),
26
- timestamp: m.string('ISO 8601 timestamp of this check'),
27
- });
28
- });
7
+ return `/**
8
+ * System Model — MVA Domain Layer (defineModel)
9
+ *
10
+ * Defines the shape of system health data using defineModel().
11
+ * The Model provides:
12
+ * - Field types with m.string(), m.number(), etc.
13
+ * - .describe() annotations that become JIT system rules
14
+ * - Validation and casting for the domain entity
15
+ *
16
+ * The Presenter references this Model instead of raw z.object(),
17
+ * keeping a single source of truth for the data shape.
18
+ */
19
+ import { defineModel } from '@vurb/core';
20
+
21
+ export const SystemModel = defineModel('SystemHealth', m => {
22
+ m.casts({
23
+ status: m.string('Server operational status'),
24
+ uptime: m.number('Uptime in seconds since process start'),
25
+ version: m.string('Server version string'),
26
+ timestamp: m.string('ISO 8601 timestamp of this check'),
27
+ });
28
+ });
29
29
  `;
30
30
  }
31
31
  //# sourceMappingURL=model.js.map