nitrostack 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/CHANGELOG.md +227 -0
- package/CONTRIBUTING.md +182 -0
- package/LICENSE +201 -0
- package/LICENSE_URLS_UPDATE_COMPLETE.md +388 -0
- package/NOTICE +153 -0
- package/README.md +571 -0
- package/dist/auth/api-key.d.ts +118 -0
- package/dist/auth/api-key.d.ts.map +1 -0
- package/dist/auth/api-key.js +168 -0
- package/dist/auth/api-key.js.map +1 -0
- package/dist/auth/client.d.ts +151 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/client.js +330 -0
- package/dist/auth/client.js.map +1 -0
- package/dist/auth/index.d.ts +30 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +43 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/middleware.d.ts +95 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +260 -0
- package/dist/auth/middleware.js.map +1 -0
- package/dist/auth/pkce.d.ts +53 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +105 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/quick-setup.d.ts +94 -0
- package/dist/auth/quick-setup.d.ts.map +1 -0
- package/dist/auth/quick-setup.js +210 -0
- package/dist/auth/quick-setup.js.map +1 -0
- package/dist/auth/server-integration.d.ts +97 -0
- package/dist/auth/server-integration.d.ts.map +1 -0
- package/dist/auth/server-integration.js +182 -0
- package/dist/auth/server-integration.js.map +1 -0
- package/dist/auth/server-metadata.d.ts +51 -0
- package/dist/auth/server-metadata.d.ts.map +1 -0
- package/dist/auth/server-metadata.js +106 -0
- package/dist/auth/server-metadata.js.map +1 -0
- package/dist/auth/simple-jwt.d.ts +88 -0
- package/dist/auth/simple-jwt.d.ts.map +1 -0
- package/dist/auth/simple-jwt.js +152 -0
- package/dist/auth/simple-jwt.js.map +1 -0
- package/dist/auth/token-store.d.ts +104 -0
- package/dist/auth/token-store.d.ts.map +1 -0
- package/dist/auth/token-store.js +205 -0
- package/dist/auth/token-store.js.map +1 -0
- package/dist/auth/token-validation.d.ts +47 -0
- package/dist/auth/token-validation.d.ts.map +1 -0
- package/dist/auth/token-validation.js +237 -0
- package/dist/auth/token-validation.js.map +1 -0
- package/dist/auth/types.d.ts +215 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +6 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/cli/commands/build.d.ts +6 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +104 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +7 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +312 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/generate-types.d.ts +8 -0
- package/dist/cli/commands/generate-types.d.ts.map +1 -0
- package/dist/cli/commands/generate-types.js +220 -0
- package/dist/cli/commands/generate-types.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +5 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +365 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/init.d.ts +7 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +365 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/start.d.ts +6 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +61 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +47 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/mcp-dev-wrapper.d.ts +3 -0
- package/dist/cli/mcp-dev-wrapper.d.ts.map +1 -0
- package/dist/cli/mcp-dev-wrapper.js +116 -0
- package/dist/cli/mcp-dev-wrapper.js.map +1 -0
- package/dist/core/apikey-module.d.ts +69 -0
- package/dist/core/apikey-module.d.ts.map +1 -0
- package/dist/core/apikey-module.js +114 -0
- package/dist/core/apikey-module.js.map +1 -0
- package/dist/core/app-decorator.d.ts +58 -0
- package/dist/core/app-decorator.d.ts.map +1 -0
- package/dist/core/app-decorator.js +261 -0
- package/dist/core/app-decorator.js.map +1 -0
- package/dist/core/builders.d.ts +38 -0
- package/dist/core/builders.d.ts.map +1 -0
- package/dist/core/builders.js +129 -0
- package/dist/core/builders.js.map +1 -0
- package/dist/core/component.d.ts +105 -0
- package/dist/core/component.d.ts.map +1 -0
- package/dist/core/component.js +182 -0
- package/dist/core/component.js.map +1 -0
- package/dist/core/config-module.d.ts +55 -0
- package/dist/core/config-module.d.ts.map +1 -0
- package/dist/core/config-module.js +94 -0
- package/dist/core/config-module.js.map +1 -0
- package/dist/core/decorators/cache.decorator.d.ts +61 -0
- package/dist/core/decorators/cache.decorator.d.ts.map +1 -0
- package/dist/core/decorators/cache.decorator.js +115 -0
- package/dist/core/decorators/cache.decorator.js.map +1 -0
- package/dist/core/decorators/health-check.decorator.d.ts +80 -0
- package/dist/core/decorators/health-check.decorator.d.ts.map +1 -0
- package/dist/core/decorators/health-check.decorator.js +153 -0
- package/dist/core/decorators/health-check.decorator.js.map +1 -0
- package/dist/core/decorators/rate-limit.decorator.d.ts +62 -0
- package/dist/core/decorators/rate-limit.decorator.d.ts.map +1 -0
- package/dist/core/decorators/rate-limit.decorator.js +129 -0
- package/dist/core/decorators/rate-limit.decorator.js.map +1 -0
- package/dist/core/decorators.d.ts +151 -0
- package/dist/core/decorators.d.ts.map +1 -0
- package/dist/core/decorators.js +142 -0
- package/dist/core/decorators.js.map +1 -0
- package/dist/core/di/container.d.ts +42 -0
- package/dist/core/di/container.d.ts.map +1 -0
- package/dist/core/di/container.js +76 -0
- package/dist/core/di/container.js.map +1 -0
- package/dist/core/di/injectable.decorator.d.ts +35 -0
- package/dist/core/di/injectable.decorator.d.ts.map +1 -0
- package/dist/core/di/injectable.decorator.js +57 -0
- package/dist/core/di/injectable.decorator.js.map +1 -0
- package/dist/core/errors.d.ts +54 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +87 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/events/event-emitter.d.ts +50 -0
- package/dist/core/events/event-emitter.d.ts.map +1 -0
- package/dist/core/events/event-emitter.js +94 -0
- package/dist/core/events/event-emitter.js.map +1 -0
- package/dist/core/events/event.decorator.d.ts +48 -0
- package/dist/core/events/event.decorator.d.ts.map +1 -0
- package/dist/core/events/event.decorator.js +68 -0
- package/dist/core/events/event.decorator.js.map +1 -0
- package/dist/core/filters/exception-filter.decorator.d.ts +40 -0
- package/dist/core/filters/exception-filter.decorator.d.ts.map +1 -0
- package/dist/core/filters/exception-filter.decorator.js +54 -0
- package/dist/core/filters/exception-filter.decorator.js.map +1 -0
- package/dist/core/filters/exception-filter.interface.d.ts +30 -0
- package/dist/core/filters/exception-filter.interface.d.ts.map +1 -0
- package/dist/core/filters/exception-filter.interface.js +2 -0
- package/dist/core/filters/exception-filter.interface.js.map +1 -0
- package/dist/core/guards/apikey.guard.d.ts +22 -0
- package/dist/core/guards/apikey.guard.d.ts.map +1 -0
- package/dist/core/guards/apikey.guard.js +11 -0
- package/dist/core/guards/apikey.guard.js.map +1 -0
- package/dist/core/guards/guard.interface.d.ts +18 -0
- package/dist/core/guards/guard.interface.d.ts.map +1 -0
- package/dist/core/guards/guard.interface.js +2 -0
- package/dist/core/guards/guard.interface.js.map +1 -0
- package/dist/core/guards/jwt.guard.d.ts +18 -0
- package/dist/core/guards/jwt.guard.d.ts.map +1 -0
- package/dist/core/guards/jwt.guard.js +2 -0
- package/dist/core/guards/jwt.guard.js.map +1 -0
- package/dist/core/guards/oauth.guard.d.ts +35 -0
- package/dist/core/guards/oauth.guard.d.ts.map +1 -0
- package/dist/core/guards/oauth.guard.js +2 -0
- package/dist/core/guards/oauth.guard.js.map +1 -0
- package/dist/core/guards/use-guards.decorator.d.ts +25 -0
- package/dist/core/guards/use-guards.decorator.d.ts.map +1 -0
- package/dist/core/guards/use-guards.decorator.js +32 -0
- package/dist/core/guards/use-guards.decorator.js.map +1 -0
- package/dist/core/health/health-checks.resource.d.ts +14 -0
- package/dist/core/health/health-checks.resource.d.ts.map +1 -0
- package/dist/core/health/health-checks.resource.js +29 -0
- package/dist/core/health/health-checks.resource.js.map +1 -0
- package/dist/core/index.d.ts +55 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +57 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/interceptors/interceptor.decorator.d.ts +37 -0
- package/dist/core/interceptors/interceptor.decorator.d.ts.map +1 -0
- package/dist/core/interceptors/interceptor.decorator.js +51 -0
- package/dist/core/interceptors/interceptor.decorator.js.map +1 -0
- package/dist/core/interceptors/interceptor.interface.d.ts +31 -0
- package/dist/core/interceptors/interceptor.interface.d.ts.map +1 -0
- package/dist/core/interceptors/interceptor.interface.js +2 -0
- package/dist/core/interceptors/interceptor.interface.js.map +1 -0
- package/dist/core/jwt-module.d.ts +51 -0
- package/dist/core/jwt-module.d.ts.map +1 -0
- package/dist/core/jwt-module.js +52 -0
- package/dist/core/jwt-module.js.map +1 -0
- package/dist/core/logger.d.ts +18 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +51 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/middleware/middleware.decorator.d.ts +39 -0
- package/dist/core/middleware/middleware.decorator.d.ts.map +1 -0
- package/dist/core/middleware/middleware.decorator.js +53 -0
- package/dist/core/middleware/middleware.decorator.js.map +1 -0
- package/dist/core/middleware/middleware.interface.d.ts +29 -0
- package/dist/core/middleware/middleware.interface.d.ts.map +1 -0
- package/dist/core/middleware/middleware.interface.js +2 -0
- package/dist/core/middleware/middleware.interface.js.map +1 -0
- package/dist/core/module.d.ts +74 -0
- package/dist/core/module.d.ts.map +1 -0
- package/dist/core/module.js +82 -0
- package/dist/core/module.js.map +1 -0
- package/dist/core/oauth-module.d.ts +144 -0
- package/dist/core/oauth-module.d.ts.map +1 -0
- package/dist/core/oauth-module.js +190 -0
- package/dist/core/oauth-module.js.map +1 -0
- package/dist/core/pipes/pipe.decorator.d.ts +55 -0
- package/dist/core/pipes/pipe.decorator.d.ts.map +1 -0
- package/dist/core/pipes/pipe.decorator.js +85 -0
- package/dist/core/pipes/pipe.decorator.js.map +1 -0
- package/dist/core/pipes/pipe.interface.d.ts +36 -0
- package/dist/core/pipes/pipe.interface.d.ts.map +1 -0
- package/dist/core/pipes/pipe.interface.js +2 -0
- package/dist/core/pipes/pipe.interface.js.map +1 -0
- package/dist/core/prompt.d.ts +37 -0
- package/dist/core/prompt.d.ts.map +1 -0
- package/dist/core/prompt.js +76 -0
- package/dist/core/prompt.js.map +1 -0
- package/dist/core/resource.d.ts +42 -0
- package/dist/core/resource.d.ts.map +1 -0
- package/dist/core/resource.js +90 -0
- package/dist/core/resource.js.map +1 -0
- package/dist/core/server.d.ts +72 -0
- package/dist/core/server.d.ts.map +1 -0
- package/dist/core/server.js +406 -0
- package/dist/core/server.js.map +1 -0
- package/dist/core/tool.d.ts +78 -0
- package/dist/core/tool.d.ts.map +1 -0
- package/dist/core/tool.js +190 -0
- package/dist/core/tool.js.map +1 -0
- package/dist/core/transports/http-server.d.ts +102 -0
- package/dist/core/transports/http-server.d.ts.map +1 -0
- package/dist/core/transports/http-server.js +265 -0
- package/dist/core/transports/http-server.js.map +1 -0
- package/dist/core/types.d.ts +123 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/widgets/widget-examples.resource.d.ts +17 -0
- package/dist/core/widgets/widget-examples.resource.d.ts.map +1 -0
- package/dist/core/widgets/widget-examples.resource.js +28 -0
- package/dist/core/widgets/widget-examples.resource.js.map +1 -0
- package/dist/core/widgets/widget-registry.d.ts +56 -0
- package/dist/core/widgets/widget-registry.d.ts.map +1 -0
- package/dist/core/widgets/widget-registry.js +75 -0
- package/dist/core/widgets/widget-registry.js.map +1 -0
- package/dist/testing/index.d.ts +82 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +164 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/ui-next/index.d.ts +31 -0
- package/dist/ui-next/index.d.ts.map +1 -0
- package/dist/ui-next/index.js +687 -0
- package/dist/ui-next/index.js.map +1 -0
- package/dist/widgets/index.d.ts +9 -0
- package/dist/widgets/index.d.ts.map +1 -0
- package/dist/widgets/index.js +9 -0
- package/dist/widgets/index.js.map +1 -0
- package/dist/widgets/metadata.d.ts +53 -0
- package/dist/widgets/metadata.d.ts.map +1 -0
- package/dist/widgets/metadata.js +29 -0
- package/dist/widgets/metadata.js.map +1 -0
- package/dist/widgets/withToolData.d.ts +19 -0
- package/dist/widgets/withToolData.d.ts.map +1 -0
- package/dist/widgets/withToolData.js +240 -0
- package/dist/widgets/withToolData.js.map +1 -0
- package/jest.config.js +21 -0
- package/package.json +108 -0
- package/templates/typescript-auth/AI_AGENT_CLI_REFERENCE.md +702 -0
- package/templates/typescript-auth/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-auth/README.md +400 -0
- package/templates/typescript-auth/package.json +44 -0
- package/templates/typescript-auth-api-key/AI_AGENT_CLI_REFERENCE.md +701 -0
- package/templates/typescript-auth-api-key/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-auth-api-key/README.md +483 -0
- package/templates/typescript-auth-api-key/package-lock.json +124 -0
- package/templates/typescript-auth-api-key/package.json +29 -0
- package/templates/typescript-oauth/AI_AGENT_CLI_REFERENCE.md +701 -0
- package/templates/typescript-oauth/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-oauth/OAUTH_SETUP.md +406 -0
- package/templates/typescript-oauth/README.md +350 -0
- package/templates/typescript-oauth/package.json +30 -0
- package/templates/typescript-starter/AI_AGENT_CLI_REFERENCE.md +701 -0
- package/templates/typescript-starter/AI_AGENT_SDK_REFERENCE.md +1260 -0
- package/templates/typescript-starter/README.md +312 -0
- package/templates/typescript-starter/package.json +32 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Metadata keys for decorators
|
|
5
|
+
*/
|
|
6
|
+
export declare const TOOL_METADATA: unique symbol;
|
|
7
|
+
export declare const WIDGET_METADATA: unique symbol;
|
|
8
|
+
export declare const RESOURCE_METADATA: unique symbol;
|
|
9
|
+
export declare const PROMPT_METADATA: unique symbol;
|
|
10
|
+
export declare const GUARDS_METADATA: unique symbol;
|
|
11
|
+
/**
|
|
12
|
+
* Tool decorator options
|
|
13
|
+
*/
|
|
14
|
+
export interface ToolOptions {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: z.ZodSchema;
|
|
18
|
+
examples?: {
|
|
19
|
+
request?: any;
|
|
20
|
+
response?: any;
|
|
21
|
+
};
|
|
22
|
+
metadata?: {
|
|
23
|
+
category?: string;
|
|
24
|
+
tags?: string[];
|
|
25
|
+
rateLimit?: {
|
|
26
|
+
maxCalls: number;
|
|
27
|
+
windowMs: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resource decorator options
|
|
33
|
+
*/
|
|
34
|
+
export interface ResourceOptions {
|
|
35
|
+
uri: string;
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
mimeType?: string;
|
|
39
|
+
examples?: {
|
|
40
|
+
response?: any;
|
|
41
|
+
};
|
|
42
|
+
metadata?: {
|
|
43
|
+
cacheable?: boolean;
|
|
44
|
+
cacheMaxAge?: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Prompt decorator options
|
|
49
|
+
*/
|
|
50
|
+
export interface PromptOptions {
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
arguments?: Array<{
|
|
54
|
+
name: string;
|
|
55
|
+
description: string;
|
|
56
|
+
required?: boolean;
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Tool decorator - Marks a method as an MCP tool
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* @Tool({
|
|
65
|
+
* name: 'login',
|
|
66
|
+
* description: 'Login with email and password',
|
|
67
|
+
* inputSchema: z.object({
|
|
68
|
+
* email: z.string().email(),
|
|
69
|
+
* password: z.string(),
|
|
70
|
+
* }),
|
|
71
|
+
* })
|
|
72
|
+
* async login(input: any, context: ExecutionContext) {
|
|
73
|
+
* // Implementation
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function Tool(options: ToolOptions): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
78
|
+
/**
|
|
79
|
+
* Widget decorator - Links a tool to a Next.js widget route
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* @Tool({ name: 'login', ... })
|
|
84
|
+
* @Widget('login-result')
|
|
85
|
+
* async login(input: any, context: ExecutionContext) {
|
|
86
|
+
* // Implementation
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function Widget(routePath: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
91
|
+
/**
|
|
92
|
+
* Resource decorator - Marks a method as an MCP resource
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* @Resource({
|
|
97
|
+
* uri: 'db://users/schema',
|
|
98
|
+
* name: 'User Schema',
|
|
99
|
+
* description: 'Database schema for users',
|
|
100
|
+
* })
|
|
101
|
+
* async getUserSchema(context: ExecutionContext) {
|
|
102
|
+
* // Return schema
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare function Resource(options: ResourceOptions): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
107
|
+
/**
|
|
108
|
+
* Prompt decorator - Marks a method as an MCP prompt
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* @Prompt({
|
|
113
|
+
* name: 'authentication-help',
|
|
114
|
+
* description: 'Help with authentication',
|
|
115
|
+
* })
|
|
116
|
+
* async authHelp(args: any, context: ExecutionContext) {
|
|
117
|
+
* // Return prompt messages
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare function Prompt(options: PromptOptions): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
122
|
+
/**
|
|
123
|
+
* Extract tool definitions from a decorated class
|
|
124
|
+
*/
|
|
125
|
+
export declare function extractTools(target: any): Array<{
|
|
126
|
+
methodName: string;
|
|
127
|
+
options: ToolOptions;
|
|
128
|
+
}>;
|
|
129
|
+
/**
|
|
130
|
+
* Extract resource definitions from a decorated class
|
|
131
|
+
*/
|
|
132
|
+
export declare function extractResources(target: any): Array<{
|
|
133
|
+
methodName: string;
|
|
134
|
+
options: ResourceOptions;
|
|
135
|
+
}>;
|
|
136
|
+
/**
|
|
137
|
+
* Extract prompt definitions from a decorated class
|
|
138
|
+
*/
|
|
139
|
+
export declare function extractPrompts(target: any): Array<{
|
|
140
|
+
methodName: string;
|
|
141
|
+
options: PromptOptions;
|
|
142
|
+
}>;
|
|
143
|
+
/**
|
|
144
|
+
* Get widget metadata for a specific method
|
|
145
|
+
*/
|
|
146
|
+
export declare function getWidgetMetadata(target: any, methodName: string): string | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* Get guards metadata for a specific method
|
|
149
|
+
*/
|
|
150
|
+
export declare function getGuardsMetadata(target: any, methodName: string): any[];
|
|
151
|
+
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/core/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,aAAa,eAA0B,CAAC;AACrD,eAAO,MAAM,eAAe,eAA4B,CAAC;AACzD,eAAO,MAAM,iBAAiB,eAA8B,CAAC;AAC7D,eAAO,MAAM,eAAe,eAA4B,CAAC;AACzD,eAAO,MAAM,eAAe,eAA4B,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC;IACzB,QAAQ,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,GAAG,CAAC;QACd,QAAQ,CAAC,EAAE,GAAG,CAAC;KAChB,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,SAAS,CAAC,EAAE;YACV,QAAQ,EAAE,MAAM,CAAC;YACjB,QAAQ,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE;QACT,QAAQ,CAAC,EAAE,GAAG,CAAC;KAChB,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED;;GAEG;AACH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C,CAEjG;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAErF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,GAAG,EAAE,CAExE"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
/**
|
|
3
|
+
* Metadata keys for decorators
|
|
4
|
+
*/
|
|
5
|
+
export const TOOL_METADATA = Symbol('tool:metadata');
|
|
6
|
+
export const WIDGET_METADATA = Symbol('widget:metadata');
|
|
7
|
+
export const RESOURCE_METADATA = Symbol('resource:metadata');
|
|
8
|
+
export const PROMPT_METADATA = Symbol('prompt:metadata');
|
|
9
|
+
export const GUARDS_METADATA = Symbol('guards:metadata');
|
|
10
|
+
/**
|
|
11
|
+
* Tool decorator - Marks a method as an MCP tool
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* @Tool({
|
|
16
|
+
* name: 'login',
|
|
17
|
+
* description: 'Login with email and password',
|
|
18
|
+
* inputSchema: z.object({
|
|
19
|
+
* email: z.string().email(),
|
|
20
|
+
* password: z.string(),
|
|
21
|
+
* }),
|
|
22
|
+
* })
|
|
23
|
+
* async login(input: any, context: ExecutionContext) {
|
|
24
|
+
* // Implementation
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function Tool(options) {
|
|
29
|
+
return function (target, propertyKey, descriptor) {
|
|
30
|
+
// Get existing tools or create new array
|
|
31
|
+
const existingTools = Reflect.getMetadata(TOOL_METADATA, target.constructor) || [];
|
|
32
|
+
// Add this tool
|
|
33
|
+
existingTools.push({
|
|
34
|
+
methodName: propertyKey,
|
|
35
|
+
options,
|
|
36
|
+
});
|
|
37
|
+
// Store metadata on the class constructor
|
|
38
|
+
Reflect.defineMetadata(TOOL_METADATA, existingTools, target.constructor);
|
|
39
|
+
return descriptor;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Widget decorator - Links a tool to a Next.js widget route
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* @Tool({ name: 'login', ... })
|
|
48
|
+
* @Widget('login-result')
|
|
49
|
+
* async login(input: any, context: ExecutionContext) {
|
|
50
|
+
* // Implementation
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function Widget(routePath) {
|
|
55
|
+
return function (target, propertyKey, descriptor) {
|
|
56
|
+
// Store widget metadata
|
|
57
|
+
Reflect.defineMetadata(WIDGET_METADATA, routePath, target, propertyKey);
|
|
58
|
+
return descriptor;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resource decorator - Marks a method as an MCP resource
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* @Resource({
|
|
67
|
+
* uri: 'db://users/schema',
|
|
68
|
+
* name: 'User Schema',
|
|
69
|
+
* description: 'Database schema for users',
|
|
70
|
+
* })
|
|
71
|
+
* async getUserSchema(context: ExecutionContext) {
|
|
72
|
+
* // Return schema
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export function Resource(options) {
|
|
77
|
+
return function (target, propertyKey, descriptor) {
|
|
78
|
+
const existingResources = Reflect.getMetadata(RESOURCE_METADATA, target.constructor) || [];
|
|
79
|
+
existingResources.push({
|
|
80
|
+
methodName: propertyKey,
|
|
81
|
+
options,
|
|
82
|
+
});
|
|
83
|
+
Reflect.defineMetadata(RESOURCE_METADATA, existingResources, target.constructor);
|
|
84
|
+
return descriptor;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Prompt decorator - Marks a method as an MCP prompt
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* @Prompt({
|
|
93
|
+
* name: 'authentication-help',
|
|
94
|
+
* description: 'Help with authentication',
|
|
95
|
+
* })
|
|
96
|
+
* async authHelp(args: any, context: ExecutionContext) {
|
|
97
|
+
* // Return prompt messages
|
|
98
|
+
* }
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export function Prompt(options) {
|
|
102
|
+
return function (target, propertyKey, descriptor) {
|
|
103
|
+
const existingPrompts = Reflect.getMetadata(PROMPT_METADATA, target.constructor) || [];
|
|
104
|
+
existingPrompts.push({
|
|
105
|
+
methodName: propertyKey,
|
|
106
|
+
options,
|
|
107
|
+
});
|
|
108
|
+
Reflect.defineMetadata(PROMPT_METADATA, existingPrompts, target.constructor);
|
|
109
|
+
return descriptor;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Extract tool definitions from a decorated class
|
|
114
|
+
*/
|
|
115
|
+
export function extractTools(target) {
|
|
116
|
+
return Reflect.getMetadata(TOOL_METADATA, target) || [];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Extract resource definitions from a decorated class
|
|
120
|
+
*/
|
|
121
|
+
export function extractResources(target) {
|
|
122
|
+
return Reflect.getMetadata(RESOURCE_METADATA, target) || [];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Extract prompt definitions from a decorated class
|
|
126
|
+
*/
|
|
127
|
+
export function extractPrompts(target) {
|
|
128
|
+
return Reflect.getMetadata(PROMPT_METADATA, target) || [];
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Get widget metadata for a specific method
|
|
132
|
+
*/
|
|
133
|
+
export function getWidgetMetadata(target, methodName) {
|
|
134
|
+
return Reflect.getMetadata(WIDGET_METADATA, target, methodName);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get guards metadata for a specific method
|
|
138
|
+
*/
|
|
139
|
+
export function getGuardsMetadata(target, methodName) {
|
|
140
|
+
return Reflect.getMetadata(GUARDS_METADATA, target, methodName) || [];
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=decorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/core/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAG1B;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAqDzD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,IAAI,CAAC,OAAoB;IACvC,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC/E,yCAAyC;QACzC,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAEnF,gBAAgB;QAChB,aAAa,CAAC,IAAI,CAAC;YACjB,UAAU,EAAE,WAAW;YACvB,OAAO;SACR,CAAC,CAAC;QAEH,0CAA0C;QAC1C,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,aAAa,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAEzE,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,MAAM,CAAC,SAAiB;IACtC,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAE,UAA8B;QAC/E,wBAAwB;QACxB,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O,CAAC,WAAW,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAAW;IACxC,OAAO,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAW,EAAE,UAAkB;IAC/D,OAAO,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;AAClE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAW,EAAE,UAAkB;IAC/D,OAAO,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
/**
|
|
3
|
+
* Dependency Injection Container
|
|
4
|
+
*
|
|
5
|
+
* Simple DI container for managing service instances and dependencies.
|
|
6
|
+
* Supports constructor injection and singleton pattern.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DIContainer {
|
|
9
|
+
private static instance;
|
|
10
|
+
private providers;
|
|
11
|
+
private instances;
|
|
12
|
+
private constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Get the singleton container instance
|
|
15
|
+
*/
|
|
16
|
+
static getInstance(): DIContainer;
|
|
17
|
+
/**
|
|
18
|
+
* Register a provider (class)
|
|
19
|
+
*/
|
|
20
|
+
register(token: any, provider?: any): void;
|
|
21
|
+
/**
|
|
22
|
+
* Register a value directly
|
|
23
|
+
*/
|
|
24
|
+
registerValue(token: any, value: any): void;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve a dependency (get or create instance)
|
|
27
|
+
*/
|
|
28
|
+
resolve<T>(token: any): T;
|
|
29
|
+
/**
|
|
30
|
+
* Get constructor dependencies from metadata
|
|
31
|
+
*/
|
|
32
|
+
private getDependencies;
|
|
33
|
+
/**
|
|
34
|
+
* Clear all registrations (useful for testing)
|
|
35
|
+
*/
|
|
36
|
+
clear(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Check if a token is registered
|
|
39
|
+
*/
|
|
40
|
+
has(token: any): boolean;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=container.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/core/di/container.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B;;;;;GAKG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IACrC,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,SAAS,CAA4B;IAE7C,OAAO;IAEP;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,WAAW;IAOjC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,IAAI;IAI1C;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAI3C;;OAEG;IACH,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC;IAwBzB;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,GAAG,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO;CAGzB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
/**
|
|
3
|
+
* Dependency Injection Container
|
|
4
|
+
*
|
|
5
|
+
* Simple DI container for managing service instances and dependencies.
|
|
6
|
+
* Supports constructor injection and singleton pattern.
|
|
7
|
+
*/
|
|
8
|
+
export class DIContainer {
|
|
9
|
+
static instance;
|
|
10
|
+
providers = new Map();
|
|
11
|
+
instances = new Map();
|
|
12
|
+
constructor() { }
|
|
13
|
+
/**
|
|
14
|
+
* Get the singleton container instance
|
|
15
|
+
*/
|
|
16
|
+
static getInstance() {
|
|
17
|
+
if (!DIContainer.instance) {
|
|
18
|
+
DIContainer.instance = new DIContainer();
|
|
19
|
+
}
|
|
20
|
+
return DIContainer.instance;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Register a provider (class)
|
|
24
|
+
*/
|
|
25
|
+
register(token, provider) {
|
|
26
|
+
this.providers.set(token, provider || token);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Register a value directly
|
|
30
|
+
*/
|
|
31
|
+
registerValue(token, value) {
|
|
32
|
+
this.instances.set(token, value);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve a dependency (get or create instance)
|
|
36
|
+
*/
|
|
37
|
+
resolve(token) {
|
|
38
|
+
// Check if already instantiated
|
|
39
|
+
if (this.instances.has(token)) {
|
|
40
|
+
return this.instances.get(token);
|
|
41
|
+
}
|
|
42
|
+
// Get the provider
|
|
43
|
+
const provider = this.providers.get(token) || token;
|
|
44
|
+
// Get constructor dependencies
|
|
45
|
+
const dependencies = this.getDependencies(provider);
|
|
46
|
+
// Resolve dependencies recursively
|
|
47
|
+
const resolvedDependencies = dependencies.map((dep) => this.resolve(dep));
|
|
48
|
+
// Create instance
|
|
49
|
+
const instance = new provider(...resolvedDependencies);
|
|
50
|
+
// Cache instance
|
|
51
|
+
this.instances.set(token, instance);
|
|
52
|
+
return instance;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get constructor dependencies from metadata
|
|
56
|
+
*/
|
|
57
|
+
getDependencies(target) {
|
|
58
|
+
// Get design:paramtypes metadata set by TypeScript
|
|
59
|
+
const params = Reflect.getMetadata('design:paramtypes', target) || [];
|
|
60
|
+
return params;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Clear all registrations (useful for testing)
|
|
64
|
+
*/
|
|
65
|
+
clear() {
|
|
66
|
+
this.providers.clear();
|
|
67
|
+
this.instances.clear();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check if a token is registered
|
|
71
|
+
*/
|
|
72
|
+
has(token) {
|
|
73
|
+
return this.providers.has(token) || this.instances.has(token);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/core/di/container.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,CAAC,QAAQ,CAAc;IAC7B,SAAS,GAAkB,IAAI,GAAG,EAAE,CAAC;IACrC,SAAS,GAAkB,IAAI,GAAG,EAAE,CAAC;IAE7C,gBAAuB,CAAC;IAExB;;OAEG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;YAC1B,WAAW,CAAC,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;QAC3C,CAAC;QACD,OAAO,WAAW,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,KAAU,EAAE,QAAc;QACjC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,IAAI,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,KAAU,EAAE,KAAU;QAClC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,OAAO,CAAI,KAAU;QACnB,gCAAgC;QAChC,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CA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|
8
|
+
* export class UserService {
|
|
9
|
+
* constructor(private db: DatabaseService) {}
|
|
10
|
+
*
|
|
11
|
+
* async findUser(id: string) {
|
|
12
|
+
* return this.db.query('SELECT * FROM users WHERE id = ?', [id]);
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function Injectable(): ClassDecorator;
|
|
18
|
+
/**
|
|
19
|
+
* Inject a specific token (optional - for custom injection)
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* constructor(@Inject('DATABASE_CONFIG') private config: DatabaseConfig) {}
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function Inject(token: any): ParameterDecorator;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a class is injectable
|
|
29
|
+
*/
|
|
30
|
+
export declare function isInjectable(target: any): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Get inject tokens for constructor parameters
|
|
33
|
+
*/
|
|
34
|
+
export declare function getInjectTokens(target: any): any[];
|
|
35
|
+
//# sourceMappingURL=injectable.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectable.decorator.d.ts","sourceRoot":"","sources":["../../../src/core/di/injectable.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAM1B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,IAAI,cAAc,CAU3C;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,kBAAkB,CAMrD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAEjD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE,CAElD"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { DIContainer } from './container.js';
|
|
3
|
+
const INJECTABLE_KEY = 'nitrostack:injectable';
|
|
4
|
+
const INJECT_KEY = 'nitrostack:inject';
|
|
5
|
+
/**
|
|
6
|
+
* Marks a class as injectable (can be used with DI)
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* @Injectable()
|
|
11
|
+
* export class UserService {
|
|
12
|
+
* constructor(private db: DatabaseService) {}
|
|
13
|
+
*
|
|
14
|
+
* async findUser(id: string) {
|
|
15
|
+
* return this.db.query('SELECT * FROM users WHERE id = ?', [id]);
|
|
16
|
+
* }
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function Injectable() {
|
|
21
|
+
return (target) => {
|
|
22
|
+
Reflect.defineMetadata(INJECTABLE_KEY, true, target);
|
|
23
|
+
// Auto-register in DI container
|
|
24
|
+
const container = DIContainer.getInstance();
|
|
25
|
+
if (!container.has(target)) {
|
|
26
|
+
container.register(target);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Inject a specific token (optional - for custom injection)
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* constructor(@Inject('DATABASE_CONFIG') private config: DatabaseConfig) {}
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function Inject(token) {
|
|
39
|
+
return (target, propertyKey, parameterIndex) => {
|
|
40
|
+
const existingTokens = Reflect.getMetadata(INJECT_KEY, target) || [];
|
|
41
|
+
existingTokens[parameterIndex] = token;
|
|
42
|
+
Reflect.defineMetadata(INJECT_KEY, existingTokens, target);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if a class is injectable
|
|
47
|
+
*/
|
|
48
|
+
export function isInjectable(target) {
|
|
49
|
+
return Reflect.getMetadata(INJECTABLE_KEY, target) === true;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get inject tokens for constructor parameters
|
|
53
|
+
*/
|
|
54
|
+
export function getInjectTokens(target) {
|
|
55
|
+
return Reflect.getMetadata(INJECT_KEY, target) || [];
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=injectable.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectable.decorator.js","sourceRoot":"","sources":["../../../src/core/di/injectable.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAC/C,MAAM,UAAU,GAAG,mBAAmB,CAAC;AAEvC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAErD,gCAAgC;QAChC,MAAM,SAAS,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;QAC5C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3B,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,KAAU;IAC/B,OAAO,CAAC,MAAW,EAAE,WAAwC,EAAE,cAAsB,EAAE,EAAE;QACvF,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;QACrE,cAAc,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC;QACvC,OAAO,CAAC,cAAc,CAAC,UAAU,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAW;IACtC,OAAO,OAAO,CAAC,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAW;IACzC,OAAO,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for MCP server errors
|
|
3
|
+
*/
|
|
4
|
+
export declare class McpError extends Error {
|
|
5
|
+
code: string;
|
|
6
|
+
statusCode: number;
|
|
7
|
+
details?: any | undefined;
|
|
8
|
+
constructor(message: string, code: string, statusCode?: number, details?: any | undefined);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Validation error
|
|
12
|
+
*/
|
|
13
|
+
export declare class ValidationError extends McpError {
|
|
14
|
+
constructor(message: string, details?: any);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Tool not found error
|
|
18
|
+
*/
|
|
19
|
+
export declare class ToolNotFoundError extends McpError {
|
|
20
|
+
constructor(toolName: string);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resource not found error
|
|
24
|
+
*/
|
|
25
|
+
export declare class ResourceNotFoundError extends McpError {
|
|
26
|
+
constructor(uri: string);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Prompt not found error
|
|
30
|
+
*/
|
|
31
|
+
export declare class PromptNotFoundError extends McpError {
|
|
32
|
+
constructor(promptName: string);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Rate limit error
|
|
36
|
+
*/
|
|
37
|
+
export declare class RateLimitError extends McpError {
|
|
38
|
+
constructor(message?: string);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Tool execution error
|
|
42
|
+
*/
|
|
43
|
+
export declare class ToolExecutionError extends McpError {
|
|
44
|
+
constructor(toolName: string, originalError: Error);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Format error for response
|
|
48
|
+
*/
|
|
49
|
+
export declare function formatError(error: Error): {
|
|
50
|
+
code: string;
|
|
51
|
+
message: string;
|
|
52
|
+
details?: any;
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IAGxB,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,MAAM;IAClB,OAAO,CAAC,EAAE,GAAG;gBAHpB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,MAAY,EACxB,OAAO,CAAC,EAAE,GAAG,YAAA;CAMvB;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAI3C;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,QAAQ,EAAE,MAAM;CAI7B;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,QAAQ;gBACrC,GAAG,EAAE,MAAM;CAIxB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,UAAU,EAAE,MAAM;CAI/B;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,GAAE,MAA8B;CAIpD;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,QAAQ;gBAClC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK;CASnD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf,CAaA"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for MCP server errors
|
|
3
|
+
*/
|
|
4
|
+
export class McpError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
statusCode;
|
|
7
|
+
details;
|
|
8
|
+
constructor(message, code, statusCode = 500, details) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.statusCode = statusCode;
|
|
12
|
+
this.details = details;
|
|
13
|
+
this.name = 'McpError';
|
|
14
|
+
Error.captureStackTrace(this, this.constructor);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Validation error
|
|
19
|
+
*/
|
|
20
|
+
export class ValidationError extends McpError {
|
|
21
|
+
constructor(message, details) {
|
|
22
|
+
super(message, 'VALIDATION_ERROR', 400, details);
|
|
23
|
+
this.name = 'ValidationError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Tool not found error
|
|
28
|
+
*/
|
|
29
|
+
export class ToolNotFoundError extends McpError {
|
|
30
|
+
constructor(toolName) {
|
|
31
|
+
super(`Tool '${toolName}' not found`, 'TOOL_NOT_FOUND', 404);
|
|
32
|
+
this.name = 'ToolNotFoundError';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Resource not found error
|
|
37
|
+
*/
|
|
38
|
+
export class ResourceNotFoundError extends McpError {
|
|
39
|
+
constructor(uri) {
|
|
40
|
+
super(`Resource '${uri}' not found`, 'RESOURCE_NOT_FOUND', 404);
|
|
41
|
+
this.name = 'ResourceNotFoundError';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Prompt not found error
|
|
46
|
+
*/
|
|
47
|
+
export class PromptNotFoundError extends McpError {
|
|
48
|
+
constructor(promptName) {
|
|
49
|
+
super(`Prompt '${promptName}' not found`, 'PROMPT_NOT_FOUND', 404);
|
|
50
|
+
this.name = 'PromptNotFoundError';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Rate limit error
|
|
55
|
+
*/
|
|
56
|
+
export class RateLimitError extends McpError {
|
|
57
|
+
constructor(message = 'Rate limit exceeded') {
|
|
58
|
+
super(message, 'RATE_LIMIT_EXCEEDED', 429);
|
|
59
|
+
this.name = 'RateLimitError';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Tool execution error
|
|
64
|
+
*/
|
|
65
|
+
export class ToolExecutionError extends McpError {
|
|
66
|
+
constructor(toolName, originalError) {
|
|
67
|
+
super(`Error executing tool '${toolName}': ${originalError.message}`, 'TOOL_EXECUTION_ERROR', 500, { originalError: originalError.message, stack: originalError.stack });
|
|
68
|
+
this.name = 'ToolExecutionError';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Format error for response
|
|
73
|
+
*/
|
|
74
|
+
export function formatError(error) {
|
|
75
|
+
if (error instanceof McpError) {
|
|
76
|
+
return {
|
|
77
|
+
code: error.code,
|
|
78
|
+
message: error.message,
|
|
79
|
+
details: error.details,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
code: 'INTERNAL_ERROR',
|
|
84
|
+
message: error.message,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=errors.js.map
|