shokupan 0.13.0 → 0.14.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.
Files changed (97) hide show
  1. package/dist/{analyzer-BOtveWL-.cjs → analyzer-BZSVGTmP.cjs} +5 -4
  2. package/dist/analyzer-BZSVGTmP.cjs.map +1 -0
  3. package/dist/{analyzer-B0fMzeIo.js → analyzer-Faojwm7c.js} +5 -4
  4. package/dist/analyzer-Faojwm7c.js.map +1 -0
  5. package/dist/{analyzer.impl-CUDO6vpn.cjs → analyzer.impl-5aCqtook.cjs} +28 -11
  6. package/dist/analyzer.impl-5aCqtook.cjs.map +1 -0
  7. package/dist/{analyzer.impl-DmHe92Oi.js → analyzer.impl-COdN69gL.js} +28 -11
  8. package/dist/analyzer.impl-COdN69gL.js.map +1 -0
  9. package/dist/ast-analyzer-worker-C3jrQ8VR.js +184 -0
  10. package/dist/ast-analyzer-worker-C3jrQ8VR.js.map +1 -0
  11. package/dist/ast-analyzer-worker-D_uYkqmY.cjs +184 -0
  12. package/dist/ast-analyzer-worker-D_uYkqmY.cjs.map +1 -0
  13. package/dist/cli.cjs +1 -1
  14. package/dist/cli.js +1 -1
  15. package/dist/context.d.ts +39 -4
  16. package/dist/decorators/di.d.ts +31 -0
  17. package/dist/decorators/hooks.d.ts +28 -0
  18. package/dist/decorators/http.d.ts +60 -0
  19. package/dist/decorators/index.d.ts +8 -0
  20. package/dist/decorators/mcp.d.ts +48 -0
  21. package/dist/decorators/util/container.d.ts +36 -0
  22. package/dist/decorators/websocket.d.ts +172 -0
  23. package/dist/index-BP7v0Hiv.cjs +12216 -0
  24. package/dist/index-BP7v0Hiv.cjs.map +1 -0
  25. package/dist/index-CUNBeZKj.js +12176 -0
  26. package/dist/index-CUNBeZKj.js.map +1 -0
  27. package/dist/index.cjs +137 -10518
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.ts +1 -2
  30. package/dist/index.js +137 -10477
  31. package/dist/index.js.map +1 -1
  32. package/dist/{json-parser-COdZ0fqY.cjs → json-parser-BA0mUgMF.cjs} +3 -3
  33. package/dist/json-parser-BA0mUgMF.cjs.map +1 -0
  34. package/dist/{json-parser-B3dnQmCC.js → json-parser-BFM-SnBR.js} +3 -3
  35. package/dist/json-parser-BFM-SnBR.js.map +1 -0
  36. package/dist/knex-DDPXR-sQ.js +218 -0
  37. package/dist/knex-DDPXR-sQ.js.map +1 -0
  38. package/dist/knex-DghF-jjm.cjs +240 -0
  39. package/dist/knex-DghF-jjm.cjs.map +1 -0
  40. package/dist/level-BU87Jbus.js +184 -0
  41. package/dist/level-BU87Jbus.js.map +1 -0
  42. package/dist/level-DNFl2n-m.cjs +184 -0
  43. package/dist/level-DNFl2n-m.cjs.map +1 -0
  44. package/dist/plugins/application/api-explorer/static/explorer-client.mjs +54 -28
  45. package/dist/plugins/application/asyncapi/plugin.d.ts +1 -0
  46. package/dist/plugins/application/asyncapi/static/asyncapi-client.mjs +22 -11
  47. package/dist/plugins/application/dashboard/fetch-interceptor.d.ts +3 -1
  48. package/dist/plugins/application/dashboard/metrics-collector.d.ts +5 -3
  49. package/dist/plugins/application/dashboard/plugin.d.ts +36 -3
  50. package/dist/plugins/application/dashboard/static/requests.js +517 -53
  51. package/dist/plugins/application/dashboard/static/tabs.js +2 -2
  52. package/dist/plugins/application/error-view/index.d.ts +25 -0
  53. package/dist/plugins/application/error-view/reason-phrases.d.ts +1 -0
  54. package/dist/plugins/application/openapi/analyzer.d.ts +3 -1
  55. package/dist/plugins/application/openapi/analyzer.impl.d.ts +4 -2
  56. package/dist/router.d.ts +56 -21
  57. package/dist/shokupan.d.ts +25 -11
  58. package/dist/sqlite-CLrcTkti.js +180 -0
  59. package/dist/sqlite-CLrcTkti.js.map +1 -0
  60. package/dist/sqlite-n7FQ6Ja6.cjs +180 -0
  61. package/dist/sqlite-n7FQ6Ja6.cjs.map +1 -0
  62. package/dist/surreal-6QONU6xa.cjs +210 -0
  63. package/dist/surreal-6QONU6xa.cjs.map +1 -0
  64. package/dist/surreal-w7DeGVI-.js +188 -0
  65. package/dist/surreal-w7DeGVI-.js.map +1 -0
  66. package/dist/util/adapter/datastore/knex.d.ts +29 -0
  67. package/dist/util/adapter/datastore/level.d.ts +26 -0
  68. package/dist/util/adapter/datastore/sqlite.d.ts +24 -0
  69. package/dist/util/adapter/datastore/surreal.d.ts +29 -0
  70. package/dist/util/adapter/datastore.d.ts +59 -0
  71. package/dist/util/adapter/h3.d.ts +8 -0
  72. package/dist/util/adapter/index.d.ts +1 -0
  73. package/dist/util/ast-analyzer-worker.d.ts +77 -0
  74. package/dist/util/ast-worker-thread.d.ts +1 -0
  75. package/dist/util/cookie-parser.d.ts +6 -0
  76. package/dist/util/env-loader.d.ts +7 -0
  77. package/dist/util/html.d.ts +15 -0
  78. package/dist/util/ide.d.ts +9 -0
  79. package/dist/util/logger.d.ts +25 -0
  80. package/dist/util/query-string.d.ts +8 -0
  81. package/dist/util/response-transformer.d.ts +87 -0
  82. package/dist/util/symbol.d.ts +1 -0
  83. package/dist/util/types.d.ts +116 -42
  84. package/dist/websocket.d.ts +163 -0
  85. package/package.json +27 -1
  86. package/dist/analyzer-B0fMzeIo.js.map +0 -1
  87. package/dist/analyzer-BOtveWL-.cjs.map +0 -1
  88. package/dist/analyzer.impl-CUDO6vpn.cjs.map +0 -1
  89. package/dist/analyzer.impl-DmHe92Oi.js.map +0 -1
  90. package/dist/json-parser-B3dnQmCC.js.map +0 -1
  91. package/dist/json-parser-COdZ0fqY.cjs.map +0 -1
  92. package/dist/plugins/application/error-view/views/error.d.ts +0 -2
  93. package/dist/plugins/application/error-view/views/status.d.ts +0 -2
  94. package/dist/util/decorators.d.ts +0 -134
  95. package/dist/util/di.d.ts +0 -13
  96. /package/dist/{util → decorators/util}/metadata.d.ts +0 -0
  97. /package/dist/{util → decorators/util}/stack.d.ts +0 -0
@@ -0,0 +1,48 @@
1
+ export * from './di';
2
+ /**
3
+ * MCP tool configuration
4
+ */
5
+ export interface ToolConfig {
6
+ name?: string;
7
+ description?: string;
8
+ inputSchema?: any;
9
+ }
10
+ /**
11
+ * Decorator for MCP tools
12
+ * @param config
13
+ * @returns
14
+ */
15
+ export declare function Tool(config?: ToolConfig): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
16
+ /**
17
+ * MCP prompt configuration
18
+ */
19
+ export interface PromptConfig {
20
+ name?: string;
21
+ description?: string;
22
+ arguments?: {
23
+ name: string;
24
+ description?: string;
25
+ required?: boolean;
26
+ }[];
27
+ }
28
+ /**
29
+ * Decorator for MCP prompts
30
+ * @param config
31
+ * @returns
32
+ */
33
+ export declare function Prompt(config?: PromptConfig): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
34
+ /**
35
+ * MCP resource configuration
36
+ */
37
+ export interface ResourceConfig {
38
+ name?: string;
39
+ description?: string;
40
+ mimeType?: string;
41
+ }
42
+ /**
43
+ * Decorator for MCP resources
44
+ * @param uri
45
+ * @param config
46
+ * @returns
47
+ */
48
+ export declare function Resource(uri: string, config?: ResourceConfig): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Simple Dependency Injection Container
3
+ */
4
+ export declare class Container {
5
+ private static services;
6
+ private static cache;
7
+ private static resolvingStack;
8
+ /**
9
+ * Register a service instance in the container.
10
+ * @param target The constructor function of the service.
11
+ * @param instance The instance of the service to register.
12
+ */
13
+ static register<T>(target: new (...args: any[]) => T, instance: T): void;
14
+ /**
15
+ * Get a service instance from the container.
16
+ * @param target The constructor function of the service.
17
+ * @returns The instance of the service, or undefined if not found.
18
+ */
19
+ static get<T>(target: new (...args: any[]) => T): T | undefined;
20
+ /**
21
+ * Check if a service is registered in the container.
22
+ * @param target The constructor function of the service.
23
+ * @returns True if the service is registered, false otherwise.
24
+ */
25
+ static has(target: any): boolean;
26
+ /**
27
+ * Resolve a service instance from the container.
28
+ * @param target The constructor function of the service.
29
+ * @returns The instance of the service, or undefined if not found.
30
+ */
31
+ static resolve<T>(target: new (...args: any[]) => T): T;
32
+ /**
33
+ * Teardown the container, destroying all singletons and clearing the cache.
34
+ */
35
+ static teardown(): Promise<void>;
36
+ }
@@ -0,0 +1,172 @@
1
+ /**
2
+ * WebSocket controller metadata
3
+ * @internal
4
+ */
5
+ export interface WebSocketMetadata {
6
+ isWebSocketController: boolean;
7
+ path?: string;
8
+ }
9
+ /**
10
+ * Event metadata
11
+ * @internal
12
+ */
13
+ export interface EventMetadata {
14
+ event: string;
15
+ methodName: string;
16
+ }
17
+ /**
18
+ * Marks a class as a WebSocket controller.
19
+ *
20
+ * @param path Optional base path for the WebSocket endpoint
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * @WebsocketController()
25
+ * class ChatController {
26
+ * @OnOpen()
27
+ * handleOpen(ctx: ShokupanContext, ws: WebSocket) {
28
+ * return { userId: "123" };
29
+ * }
30
+ * }
31
+ *
32
+ * app.mount('/chat', ChatController);
33
+ * ```
34
+ */
35
+ export declare function WebsocketController(path?: string): ClassDecorator;
36
+ /**
37
+ * Decorator for WebSocket upgrade validation handler.
38
+ * Return false to reject the upgrade.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * @OnUpgrade()
43
+ * handleUpgrade(ctx: ShokupanContext) {
44
+ * if (!ctx.get("authorization")) return false;
45
+ * return true;
46
+ * }
47
+ * ```
48
+ */
49
+ export declare function OnUpgrade(): MethodDecorator;
50
+ /**
51
+ * Decorator for WebSocket open handler.
52
+ * Return value is automatically set to ws.data and ctx.state.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * @OnOpen()
57
+ * handleOpen(ctx: ShokupanContext, ws: WebSocket) {
58
+ * return { userId: getUserId(ctx) };
59
+ * }
60
+ * ```
61
+ */
62
+ export declare function OnOpen(): MethodDecorator;
63
+ /**
64
+ * Decorator for event middleware handler.
65
+ * Runs before routing to specific event handlers.
66
+ * Return false or throw to prevent event routing.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * @OnEvent()
71
+ * handleEvent(ctx: ShokupanContext, ws: WebSocket, event: string, data: any) {
72
+ * if (event.startsWith("_")) return false; // Block private events
73
+ * }
74
+ * ```
75
+ */
76
+ export declare function OnEvent(): MethodDecorator;
77
+ /**
78
+ * Decorator for raw message handler.
79
+ * Called for every message before event parsing/routing.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * @OnMessage()
84
+ * handleMessage(ctx: ShokupanContext, ws: WebSocket, msg: string) {
85
+ * console.log("Received:", msg);
86
+ * }
87
+ * ```
88
+ */
89
+ export declare function OnMessage(): MethodDecorator;
90
+ /**
91
+ * Decorator for WebSocket close handler.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * @OnClose()
96
+ * handleClose(ctx: ShokupanContext, ws: WebSocket) {
97
+ * console.log("Client disconnected");
98
+ * }
99
+ * ```
100
+ */
101
+ export declare function OnClose(): MethodDecorator;
102
+ /**
103
+ * Decorator for WebSocket error handler.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * @OnError()
108
+ * handleError(ctx: ShokupanContext, ws: WebSocket, error: Error) {
109
+ * console.error("WebSocket error:", error);
110
+ * }
111
+ * ```
112
+ */
113
+ export declare function OnError(): MethodDecorator;
114
+ /**
115
+ * Decorator for event-specific handlers.
116
+ *
117
+ * @param event Event name to handle
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * @Event("chat.message")
122
+ * handleChatMessage(ctx: ShokupanContext, data: any) {
123
+ * ctx.broadcast("chat.message", data);
124
+ * }
125
+ * ```
126
+ */
127
+ export declare function Event(event: string): MethodDecorator;
128
+ /**
129
+ * Check if a class is a WebSocket controller.
130
+ * @internal
131
+ */
132
+ export declare function isWebSocketController(target: any): boolean;
133
+ /**
134
+ * Get WebSocket controller metadata.
135
+ * @internal
136
+ */
137
+ export declare function getWebSocketMetadata(target: any): WebSocketMetadata | undefined;
138
+ /**
139
+ * Get the onUpgrade handler method name.
140
+ * @internal
141
+ */
142
+ export declare function getUpgradeHandler(target: any): string | symbol | undefined;
143
+ /**
144
+ * Get the onOpen handler method name.
145
+ * @internal
146
+ */
147
+ export declare function getOpenHandler(target: any): string | symbol | undefined;
148
+ /**
149
+ * Get the onEvent handler method name.
150
+ * @internal
151
+ */
152
+ export declare function getEventMiddlewareHandler(target: any): string | symbol | undefined;
153
+ /**
154
+ * Get the onMessage handler method name.
155
+ * @internal
156
+ */
157
+ export declare function getMessageHandler(target: any): string | symbol | undefined;
158
+ /**
159
+ * Get the onClose handler method name.
160
+ * @internal
161
+ */
162
+ export declare function getCloseHandler(target: any): string | symbol | undefined;
163
+ /**
164
+ * Get the onError handler method name.
165
+ * @internal
166
+ */
167
+ export declare function getErrorHandler(target: any): string | symbol | undefined;
168
+ /**
169
+ * Get all event handlers.
170
+ * @internal
171
+ */
172
+ export declare function getEventHandlers(target: any): EventMetadata[];