stratal 0.0.12 → 0.0.13
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/README.md +1 -1
- package/dist/application.js +1 -1
- package/dist/application.js.map +1 -1
- package/dist/errors/application-error.d.ts +4 -3
- package/dist/errors/application-error.d.ts.map +1 -1
- package/dist/errors/application-error.js +12 -7
- package/dist/errors/application-error.js.map +1 -1
- package/dist/errors/error-codes.d.ts +4 -0
- package/dist/errors/error-codes.d.ts.map +1 -1
- package/dist/errors/error-codes.js +4 -0
- package/dist/errors/error-codes.js.map +1 -1
- package/dist/i18n/messages/en/errors.d.ts +2 -0
- package/dist/i18n/messages/en/errors.d.ts.map +1 -1
- package/dist/i18n/messages/en/errors.js +3 -0
- package/dist/i18n/messages/en/errors.js.map +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.d.ts.map +1 -1
- package/dist/openapi/index.js.map +1 -1
- package/dist/openapi/openapi.module.d.ts.map +1 -1
- package/dist/openapi/openapi.module.js +0 -1
- package/dist/openapi/openapi.module.js.map +1 -1
- package/dist/openapi/services/openapi-config.service.js +1 -1
- package/dist/openapi/services/openapi-config.service.js.map +1 -1
- package/dist/openapi/services/openapi.service.d.ts.map +1 -1
- package/dist/openapi/services/openapi.service.js +16 -13
- package/dist/openapi/services/openapi.service.js.map +1 -1
- package/dist/openapi/types.d.ts +26 -3
- package/dist/openapi/types.d.ts.map +1 -1
- package/dist/router/constants.d.ts +8 -0
- package/dist/router/constants.d.ts.map +1 -1
- package/dist/router/constants.js +9 -1
- package/dist/router/constants.js.map +1 -1
- package/dist/router/hono-app.d.ts +1 -1
- package/dist/router/hono-app.d.ts.map +1 -1
- package/dist/router/hono-app.js +2 -2
- package/dist/router/hono-app.js.map +1 -1
- package/dist/router/index.d.ts +3 -1
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js.map +1 -1
- package/dist/router/router-context.d.ts +29 -3
- package/dist/router/router-context.d.ts.map +1 -1
- package/dist/router/router-context.js +34 -0
- package/dist/router/router-context.js.map +1 -1
- package/dist/router/services/route-registration.service.d.ts +14 -1
- package/dist/router/services/route-registration.service.d.ts.map +1 -1
- package/dist/router/services/route-registration.service.js +116 -9
- package/dist/router/services/route-registration.service.js.map +1 -1
- package/dist/router/types.d.ts +25 -7
- package/dist/router/types.d.ts.map +1 -1
- package/dist/websocket/decorators/gateway.decorator.d.ts +39 -0
- package/dist/websocket/decorators/gateway.decorator.d.ts.map +1 -0
- package/dist/websocket/decorators/gateway.decorator.js +55 -0
- package/dist/websocket/decorators/gateway.decorator.js.map +1 -0
- package/dist/websocket/decorators/index.d.ts +3 -0
- package/dist/websocket/decorators/index.d.ts.map +1 -0
- package/dist/websocket/decorators/index.js +3 -0
- package/dist/websocket/decorators/index.js.map +1 -0
- package/dist/websocket/decorators/ws-event.decorator.d.ts +59 -0
- package/dist/websocket/decorators/ws-event.decorator.d.ts.map +1 -0
- package/dist/websocket/decorators/ws-event.decorator.js +94 -0
- package/dist/websocket/decorators/ws-event.decorator.js.map +1 -0
- package/dist/websocket/errors/websocket-body-not-available.error.d.ts +5 -0
- package/dist/websocket/errors/websocket-body-not-available.error.d.ts.map +1 -0
- package/dist/websocket/errors/websocket-body-not-available.error.js +7 -0
- package/dist/websocket/errors/websocket-body-not-available.error.js.map +1 -0
- package/dist/websocket/errors/websocket-duplicate-event-handler.error.d.ts +5 -0
- package/dist/websocket/errors/websocket-duplicate-event-handler.error.d.ts.map +1 -0
- package/dist/websocket/errors/websocket-duplicate-event-handler.error.js +7 -0
- package/dist/websocket/errors/websocket-duplicate-event-handler.error.js.map +1 -0
- package/dist/websocket/gateway-context.d.ts +51 -0
- package/dist/websocket/gateway-context.d.ts.map +1 -0
- package/dist/websocket/gateway-context.js +66 -0
- package/dist/websocket/gateway-context.js.map +1 -0
- package/dist/websocket/index.d.ts +7 -0
- package/dist/websocket/index.d.ts.map +1 -0
- package/dist/websocket/index.js +5 -0
- package/dist/websocket/index.js.map +1 -0
- package/dist/websocket/types.d.ts +7 -0
- package/dist/websocket/types.d.ts.map +1 -0
- package/dist/websocket/types.js +2 -0
- package/dist/websocket/types.js.map +1 -0
- package/package.json +6 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.decorator.js","sourceRoot":"","sources":["../../../src/websocket/decorators/gateway.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAI5D,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,gBAAgB,CAAA;AACjE,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,kBAAkB,CAAA;AACrE,MAAM,kBAAkB,GAAG,mBAAmB,CAAC,cAAc,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,OAAwB;IAC7D,OAAO,UAAiC,MAAS;QAC/C,SAAS,EAAE,CAAC,MAAM,CAAC,CAAA;QACnB,OAAO,CAAC,cAAc,CAAC,oBAAoB,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;QAC3D,OAAO,CAAC,cAAc,CAAC,kBAAkB,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;QACxD,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,cAAc,CAAC,sBAAsB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;QACjE,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,MAAM,cAAc,GAAG,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAE,MAAkC,CAAC,WAAW,CAAA;IAC9G,OAAO,OAAO,CAAC,WAAW,CAAC,kBAAkB,EAAE,cAAc,CAAC,KAAK,IAAI,CAAA;AACzE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/websocket/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/websocket/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Constructor } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Marks a method as the WebSocket message handler
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* @Gateway('/ws/chat')
|
|
8
|
+
* class ChatGateway {
|
|
9
|
+
* @OnMessage()
|
|
10
|
+
* handleMessage(evt: MessageEvent, ctx: GatewayContext) {
|
|
11
|
+
* ctx.send(evt.data)
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function OnMessage(): MethodDecorator;
|
|
17
|
+
/**
|
|
18
|
+
* Marks a method as the WebSocket close handler
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* @Gateway('/ws/chat')
|
|
23
|
+
* class ChatGateway {
|
|
24
|
+
* @OnClose()
|
|
25
|
+
* handleClose(evt: CloseEvent, ctx: GatewayContext) {
|
|
26
|
+
* console.log('closed')
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function OnClose(): MethodDecorator;
|
|
32
|
+
/**
|
|
33
|
+
* Marks a method as the WebSocket error handler
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* @Gateway('/ws/chat')
|
|
38
|
+
* class ChatGateway {
|
|
39
|
+
* @OnError()
|
|
40
|
+
* handleError(evt: Event, ctx: GatewayContext) {
|
|
41
|
+
* console.error('WebSocket error', evt)
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function OnError(): MethodDecorator;
|
|
47
|
+
/**
|
|
48
|
+
* Get the method name decorated with @OnMessage
|
|
49
|
+
*/
|
|
50
|
+
export declare function getWsOnMessageMethod(target: Constructor): string | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Get the method name decorated with @OnClose
|
|
53
|
+
*/
|
|
54
|
+
export declare function getWsOnCloseMethod(target: Constructor): string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Get the method name decorated with @OnError
|
|
57
|
+
*/
|
|
58
|
+
export declare function getWsOnErrorMethod(target: Constructor): string | undefined;
|
|
59
|
+
//# sourceMappingURL=ws-event.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-event.decorator.d.ts","sourceRoot":"","sources":["../../../src/websocket/decorators/ws-event.decorator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAmB9C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,IAAI,eAAe,CAM3C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,IAAI,eAAe,CAIzC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,IAAI,eAAe,CAIzC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAE5E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAE1E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAE1E"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ROUTE_METADATA_KEYS } from '../../router/constants';
|
|
2
|
+
import { WebSocketDuplicateEventHandlerError } from '../errors/websocket-duplicate-event-handler.error';
|
|
3
|
+
const WS_ON_MESSAGE_KEY = ROUTE_METADATA_KEYS.WS_ON_MESSAGE;
|
|
4
|
+
const WS_ON_CLOSE_KEY = ROUTE_METADATA_KEYS.WS_ON_CLOSE;
|
|
5
|
+
const WS_ON_ERROR_KEY = ROUTE_METADATA_KEYS.WS_ON_ERROR;
|
|
6
|
+
/**
|
|
7
|
+
* Define a single-handler metadata key on the prototype.
|
|
8
|
+
* Throws if a different method already owns this key (prevents silent override).
|
|
9
|
+
*/
|
|
10
|
+
function defineSingleHandlerMetadata(key, propertyKey, target, decoratorName) {
|
|
11
|
+
const existing = Reflect.getMetadata(key, target);
|
|
12
|
+
if (existing !== undefined && existing !== propertyKey) {
|
|
13
|
+
throw new WebSocketDuplicateEventHandlerError(decoratorName, String(existing));
|
|
14
|
+
}
|
|
15
|
+
Reflect.defineMetadata(key, propertyKey, target);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Marks a method as the WebSocket message handler
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* @Gateway('/ws/chat')
|
|
23
|
+
* class ChatGateway {
|
|
24
|
+
* @OnMessage()
|
|
25
|
+
* handleMessage(evt: MessageEvent, ctx: GatewayContext) {
|
|
26
|
+
* ctx.send(evt.data)
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function OnMessage() {
|
|
32
|
+
// `_target` is the class prototype (method decorator convention).
|
|
33
|
+
// The getter functions below read from `target.prototype` symmetrically.
|
|
34
|
+
return (_target, propertyKey) => {
|
|
35
|
+
defineSingleHandlerMetadata(WS_ON_MESSAGE_KEY, propertyKey, _target, 'OnMessage');
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Marks a method as the WebSocket close handler
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* @Gateway('/ws/chat')
|
|
44
|
+
* class ChatGateway {
|
|
45
|
+
* @OnClose()
|
|
46
|
+
* handleClose(evt: CloseEvent, ctx: GatewayContext) {
|
|
47
|
+
* console.log('closed')
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export function OnClose() {
|
|
53
|
+
return (_target, propertyKey) => {
|
|
54
|
+
defineSingleHandlerMetadata(WS_ON_CLOSE_KEY, propertyKey, _target, 'OnClose');
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Marks a method as the WebSocket error handler
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* @Gateway('/ws/chat')
|
|
63
|
+
* class ChatGateway {
|
|
64
|
+
* @OnError()
|
|
65
|
+
* handleError(evt: Event, ctx: GatewayContext) {
|
|
66
|
+
* console.error('WebSocket error', evt)
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export function OnError() {
|
|
72
|
+
return (_target, propertyKey) => {
|
|
73
|
+
defineSingleHandlerMetadata(WS_ON_ERROR_KEY, propertyKey, _target, 'OnError');
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get the method name decorated with @OnMessage
|
|
78
|
+
*/
|
|
79
|
+
export function getWsOnMessageMethod(target) {
|
|
80
|
+
return Reflect.getMetadata(WS_ON_MESSAGE_KEY, target.prototype);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Get the method name decorated with @OnClose
|
|
84
|
+
*/
|
|
85
|
+
export function getWsOnCloseMethod(target) {
|
|
86
|
+
return Reflect.getMetadata(WS_ON_CLOSE_KEY, target.prototype);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the method name decorated with @OnError
|
|
90
|
+
*/
|
|
91
|
+
export function getWsOnErrorMethod(target) {
|
|
92
|
+
return Reflect.getMetadata(WS_ON_ERROR_KEY, target.prototype);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=ws-event.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-event.decorator.js","sourceRoot":"","sources":["../../../src/websocket/decorators/ws-event.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D,OAAO,EAAE,mCAAmC,EAAE,MAAM,mDAAmD,CAAA;AAEvG,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,aAAa,CAAA;AAC3D,MAAM,eAAe,GAAG,mBAAmB,CAAC,WAAW,CAAA;AACvD,MAAM,eAAe,GAAG,mBAAmB,CAAC,WAAW,CAAA;AAEvD;;;GAGG;AACH,SAAS,2BAA2B,CAAC,GAAoB,EAAE,WAA4B,EAAE,MAAc,EAAE,aAAqB;IAC5H,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAgC,CAAA;IAChF,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;QACvD,MAAM,IAAI,mCAAmC,CAAC,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAA;IAChF,CAAC;IACD,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,CAAA;AAClD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,SAAS;IACvB,kEAAkE;IAClE,yEAAyE;IACzE,OAAO,CAAC,OAAe,EAAE,WAA4B,EAAE,EAAE;QACvD,2BAA2B,CAAC,iBAAiB,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,CAAA;IACnF,CAAC,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,OAAO;IACrB,OAAO,CAAC,OAAe,EAAE,WAA4B,EAAE,EAAE;QACvD,2BAA2B,CAAC,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;IAC/E,CAAC,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,OAAO;IACrB,OAAO,CAAC,OAAe,EAAE,WAA4B,EAAE,EAAE;QACvD,2BAA2B,CAAC,eAAe,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;IAC/E,CAAC,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAmB;IACtD,OAAO,OAAO,CAAC,WAAW,CAAC,iBAAiB,EAAE,MAAM,CAAC,SAAmB,CAAuB,CAAA;AACjG,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAmB;IACpD,OAAO,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,CAAC,SAAmB,CAAuB,CAAA;AAC/F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAmB;IACpD,OAAO,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,MAAM,CAAC,SAAmB,CAAuB,CAAA;AAC/F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-body-not-available.error.d.ts","sourceRoot":"","sources":["../../../src/websocket/errors/websocket-body-not-available.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAe,MAAM,cAAc,CAAA;AAE5D,qBAAa,8BAA+B,SAAQ,gBAAgB;;CAOnE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ApplicationError, ERROR_CODES } from '../../errors';
|
|
2
|
+
export class WebSocketBodyNotAvailableError extends ApplicationError {
|
|
3
|
+
constructor() {
|
|
4
|
+
super('errors.websocketBodyNotAvailable', ERROR_CODES.SYSTEM.WEBSOCKET_BODY_NOT_AVAILABLE);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=websocket-body-not-available.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-body-not-available.error.js","sourceRoot":"","sources":["../../../src/websocket/errors/websocket-body-not-available.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE5D,MAAM,OAAO,8BAA+B,SAAQ,gBAAgB;IAClE;QACE,KAAK,CACH,kCAAkC,EAClC,WAAW,CAAC,MAAM,CAAC,4BAA4B,CAChD,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-duplicate-event-handler.error.d.ts","sourceRoot":"","sources":["../../../src/websocket/errors/websocket-duplicate-event-handler.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAe,MAAM,cAAc,CAAA;AAE5D,qBAAa,mCAAoC,SAAQ,gBAAgB;gBAC3D,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;CAOtD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ApplicationError, ERROR_CODES } from '../../errors';
|
|
2
|
+
export class WebSocketDuplicateEventHandlerError extends ApplicationError {
|
|
3
|
+
constructor(decorator, existingMethod) {
|
|
4
|
+
super('errors.websocketDuplicateEventHandler', ERROR_CODES.SYSTEM.WEBSOCKET_DUPLICATE_EVENT_HANDLER, { decorator, existingMethod });
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=websocket-duplicate-event-handler.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-duplicate-event-handler.error.js","sourceRoot":"","sources":["../../../src/websocket/errors/websocket-duplicate-event-handler.error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE5D,MAAM,OAAO,mCAAoC,SAAQ,gBAAgB;IACvE,YAAY,SAAiB,EAAE,cAAsB;QACnD,KAAK,CACH,uCAAuC,EACvC,WAAW,CAAC,MAAM,CAAC,iCAAiC,EACpD,EAAE,SAAS,EAAE,cAAc,EAAE,CAC9B,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import type { WSContext, WSReadyState } from 'hono/ws';
|
|
3
|
+
import type { ContextQueryResult } from '../router/router-context';
|
|
4
|
+
import { RouterContext } from '../router/router-context';
|
|
5
|
+
import type { RouterEnv } from '../router/types';
|
|
6
|
+
/**
|
|
7
|
+
* WebSocket gateway context
|
|
8
|
+
*
|
|
9
|
+
* Extends RouterContext with WebSocket-specific methods.
|
|
10
|
+
* Inherits `getContainer()`, `param()`, `query()`, `header()`, `getLocale()`
|
|
11
|
+
* from RouterContext. HTTP response methods (`json()`, `redirect()`, etc.) are
|
|
12
|
+
* inherited but harmless post-upgrade.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* @OnMessage()
|
|
17
|
+
* handleMessage(evt: MessageEvent, ctx: GatewayContext) {
|
|
18
|
+
* ctx.send('ack') // convenience method
|
|
19
|
+
* ctx.header('Authorization') // upgrade request headers
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class GatewayContext extends RouterContext {
|
|
24
|
+
readonly ws: WSContext;
|
|
25
|
+
constructor(c: Context<RouterEnv>, ws: WSContext);
|
|
26
|
+
/** Send data through the WebSocket connection */
|
|
27
|
+
send(data: string | ArrayBuffer | Uint8Array<ArrayBuffer>): void;
|
|
28
|
+
/** Close the WebSocket connection */
|
|
29
|
+
close(code?: number, reason?: string): void;
|
|
30
|
+
/** Current WebSocket ready state */
|
|
31
|
+
get readyState(): WSReadyState;
|
|
32
|
+
/**
|
|
33
|
+
* Get route parameter value from the raw request (no OpenAPI validation)
|
|
34
|
+
*
|
|
35
|
+
* @param key - Parameter name (e.g., 'id' for /ws/chat/:id)
|
|
36
|
+
*/
|
|
37
|
+
param(key: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Get query parameter value from the raw request (no OpenAPI validation)
|
|
40
|
+
*
|
|
41
|
+
* @param key - Query parameter name
|
|
42
|
+
*/
|
|
43
|
+
query<R extends Record<string, unknown> | undefined = undefined, K extends string | undefined = undefined>(key?: K): ContextQueryResult<R, K>;
|
|
44
|
+
/**
|
|
45
|
+
* Request body is not available in WebSocket gateways
|
|
46
|
+
*
|
|
47
|
+
* @throws WebSocketBodyNotAvailableError always — WebSocket upgrade requests do not have a body
|
|
48
|
+
*/
|
|
49
|
+
body<T>(): Promise<T>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=gateway-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-context.d.ts","sourceRoot":"","sources":["../../src/websocket/gateway-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAGhD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,SAAQ,aAAa;aACI,EAAE,EAAE,SAAS;gBAApD,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EAAkB,EAAE,EAAE,SAAS;IAIhE,iDAAiD;IACjD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI;IAIhE,qCAAqC;IACrC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAI3C,oCAAoC;IACpC,IAAI,UAAU,IAAI,YAAY,CAE7B;IAED;;;;OAIG;IACM,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAInC;;;;OAIG;IACM,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,SAAS,EAAE,CAAC,SAAS,MAAM,GAAG,SAAS,GAAG,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC;IAOtJ;;;;OAIG;IACM,IAAI,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC;CAG/B"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { RouterContext } from '../router/router-context';
|
|
2
|
+
import { WebSocketBodyNotAvailableError } from './errors/websocket-body-not-available.error';
|
|
3
|
+
/**
|
|
4
|
+
* WebSocket gateway context
|
|
5
|
+
*
|
|
6
|
+
* Extends RouterContext with WebSocket-specific methods.
|
|
7
|
+
* Inherits `getContainer()`, `param()`, `query()`, `header()`, `getLocale()`
|
|
8
|
+
* from RouterContext. HTTP response methods (`json()`, `redirect()`, etc.) are
|
|
9
|
+
* inherited but harmless post-upgrade.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @OnMessage()
|
|
14
|
+
* handleMessage(evt: MessageEvent, ctx: GatewayContext) {
|
|
15
|
+
* ctx.send('ack') // convenience method
|
|
16
|
+
* ctx.header('Authorization') // upgrade request headers
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export class GatewayContext extends RouterContext {
|
|
21
|
+
ws;
|
|
22
|
+
constructor(c, ws) {
|
|
23
|
+
super(c);
|
|
24
|
+
this.ws = ws;
|
|
25
|
+
}
|
|
26
|
+
/** Send data through the WebSocket connection */
|
|
27
|
+
send(data) {
|
|
28
|
+
this.ws.send(data);
|
|
29
|
+
}
|
|
30
|
+
/** Close the WebSocket connection */
|
|
31
|
+
close(code, reason) {
|
|
32
|
+
this.ws.close(code, reason);
|
|
33
|
+
}
|
|
34
|
+
/** Current WebSocket ready state */
|
|
35
|
+
get readyState() {
|
|
36
|
+
return this.ws.readyState;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get route parameter value from the raw request (no OpenAPI validation)
|
|
40
|
+
*
|
|
41
|
+
* @param key - Parameter name (e.g., 'id' for /ws/chat/:id)
|
|
42
|
+
*/
|
|
43
|
+
param(key) {
|
|
44
|
+
return this.c.req.param(key);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get query parameter value from the raw request (no OpenAPI validation)
|
|
48
|
+
*
|
|
49
|
+
* @param key - Query parameter name
|
|
50
|
+
*/
|
|
51
|
+
query(key) {
|
|
52
|
+
if (key) {
|
|
53
|
+
return this.c.req.query(key);
|
|
54
|
+
}
|
|
55
|
+
return this.c.req.query();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Request body is not available in WebSocket gateways
|
|
59
|
+
*
|
|
60
|
+
* @throws WebSocketBodyNotAvailableError always — WebSocket upgrade requests do not have a body
|
|
61
|
+
*/
|
|
62
|
+
body() {
|
|
63
|
+
throw new WebSocketBodyNotAvailableError();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=gateway-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway-context.js","sourceRoot":"","sources":["../../src/websocket/gateway-context.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAA;AAE5F;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,cAAe,SAAQ,aAAa;IACI;IAAnD,YAAY,CAAqB,EAAkB,EAAa;QAC9D,KAAK,CAAC,CAAC,CAAC,CAAA;QADyC,OAAE,GAAF,EAAE,CAAW;IAEhE,CAAC;IAED,iDAAiD;IACjD,IAAI,CAAC,IAAoD;QACvD,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACpB,CAAC;IAED,qCAAqC;IACrC,KAAK,CAAC,IAAa,EAAE,MAAe;QAClC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC7B,CAAC;IAED,oCAAoC;IACpC,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAA;IAC3B,CAAC;IAED;;;;OAIG;IACM,KAAK,CAAC,GAAW;QACxB,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAE,CAAA;IAC/B,CAAC;IAED;;;;OAIG;IACM,KAAK,CAAsG,GAAO;QACzH,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAA6B,CAAA;QAC1D,CAAC;QACD,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAA8B,CAAA;IACvD,CAAC;IAED;;;;OAIG;IACM,IAAI;QACX,MAAM,IAAI,8BAA8B,EAAE,CAAA;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { WSContext, WSEvents, WSMessageReceive, WSReadyState } from 'hono/ws';
|
|
2
|
+
export { Gateway, isGateway, OnMessage, OnClose, OnError, getWsOnMessageMethod, getWsOnCloseMethod, getWsOnErrorMethod } from './decorators';
|
|
3
|
+
export { WebSocketBodyNotAvailableError } from './errors/websocket-body-not-available.error';
|
|
4
|
+
export { WebSocketDuplicateEventHandlerError } from './errors/websocket-duplicate-event-handler.error';
|
|
5
|
+
export { GatewayContext } from './gateway-context';
|
|
6
|
+
export type { GatewayOptions } from './types';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/websocket/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClF,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAC5I,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAA;AAC5F,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAA;AACtG,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Gateway, isGateway, OnMessage, OnClose, OnError, getWsOnMessageMethod, getWsOnCloseMethod, getWsOnErrorMethod } from './decorators';
|
|
2
|
+
export { WebSocketBodyNotAvailableError } from './errors/websocket-body-not-available.error';
|
|
3
|
+
export { WebSocketDuplicateEventHandlerError } from './errors/websocket-duplicate-event-handler.error';
|
|
4
|
+
export { GatewayContext } from './gateway-context';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/websocket/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAC5I,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAA;AAC5F,OAAO,EAAE,mCAAmC,EAAE,MAAM,kDAAkD,CAAA;AACtG,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ControllerOptions } from "../router/types";
|
|
2
|
+
/**
|
|
3
|
+
* Gateway options for @Gateway() decorator
|
|
4
|
+
* Subset of ControllerOptions relevant to WebSocket gateways (no OpenAPI-specific fields)
|
|
5
|
+
*/
|
|
6
|
+
export type GatewayOptions = Pick<ControllerOptions, 'version'>;
|
|
7
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/websocket/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/websocket/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stratal",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "A modular Cloudflare Workers framework with dependency injection, queue-based events, and type-safe configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -58,6 +58,10 @@
|
|
|
58
58
|
"types": "./dist/i18n/validation/index.d.ts",
|
|
59
59
|
"import": "./dist/i18n/validation/index.js"
|
|
60
60
|
},
|
|
61
|
+
"./websocket": {
|
|
62
|
+
"types": "./dist/websocket/index.d.ts",
|
|
63
|
+
"import": "./dist/websocket/index.js"
|
|
64
|
+
},
|
|
61
65
|
"./*": {
|
|
62
66
|
"types": "./dist/*/index.d.ts",
|
|
63
67
|
"import": "./dist/*/index.js"
|
|
@@ -80,10 +84,10 @@
|
|
|
80
84
|
"lint:fix": "npx eslint --fix ."
|
|
81
85
|
},
|
|
82
86
|
"dependencies": {
|
|
87
|
+
"@hono/swagger-ui": "^0.5.0",
|
|
83
88
|
"@hono/zod-openapi": "^1.2.2",
|
|
84
89
|
"@intlify/core-base": "^11.3.0",
|
|
85
90
|
"@intlify/message-compiler": "^11.3.0",
|
|
86
|
-
"@scalar/hono-api-reference": "^0.10.3",
|
|
87
91
|
"@xmldom/xmldom": "^0.8.11",
|
|
88
92
|
"hono": "^4.12.8",
|
|
89
93
|
"reflect-metadata": "^0.2.2",
|