@cloudnux/local-cloud-provider 0.11.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.
@@ -1,4 +1,6 @@
1
- import { FastifyInstance } from 'fastify';
1
+ import { FastifyRequest, FastifyReply, FastifyInstance } from 'fastify';
2
+ import { EventBatchItemResult } from '@cloudnux/core-cloud-provider';
3
+ import { WebSocket } from 'ws';
2
4
 
3
5
  interface QueueMessage {
4
6
  id: string;
@@ -12,7 +14,7 @@ interface QueueMessage {
12
14
  reprocessed?: boolean;
13
15
  originalId?: string;
14
16
  }
15
- type EventHandler = (message: QueueMessage) => Promise<void>;
17
+ type EventHandler = (message: QueueMessage) => Promise<EventBatchItemResult>;
16
18
  interface QueueService {
17
19
  handler: EventHandler;
18
20
  incoming: QueueMessage[];
@@ -148,6 +150,38 @@ declare module 'fastify' {
148
150
  }
149
151
  }
150
152
 
153
+ type WebSocketEvent = "connect" | "disconnect" | "message";
154
+ interface WebSocketConnection {
155
+ connectionId: string;
156
+ socket: WebSocket;
157
+ path: string;
158
+ connectedAt: Date;
159
+ }
160
+ type WebSocketEventHandler = (connectionId: string, event: WebSocketEvent, data: any | null, request: FastifyRequest, reply?: FastifyReply) => Promise<any>;
161
+ interface WebSocketRouteHandler {
162
+ path: string;
163
+ event: WebSocketEvent;
164
+ route?: string;
165
+ module?: string;
166
+ handler: WebSocketEventHandler;
167
+ }
168
+ interface RegisteredWebSocketPath {
169
+ path: string;
170
+ module?: string;
171
+ }
172
+ interface WebSocketManager {
173
+ registerHandler(handler: WebSocketRouteHandler): void;
174
+ getConnections(path?: string): WebSocketConnection[];
175
+ getRegisteredPaths(module?: string): RegisteredWebSocketPath[];
176
+ sendToClient(connectionId: string, data: any): Promise<void>;
177
+ disconnect(connectionId: string): Promise<void>;
178
+ }
179
+ declare module 'fastify' {
180
+ interface FastifyInstance {
181
+ websockets: WebSocketManager;
182
+ }
183
+ }
184
+
151
185
  interface DevConsolePluginOptions {
152
186
  prefix?: string;
153
187
  enableUI?: boolean;
@@ -164,6 +198,7 @@ interface RouteInfo {
164
198
  }
165
199
  declare class RouteRegistry {
166
200
  private routes;
201
+ private static readonly IGNORED_METHODS;
167
202
  register(routeOptions: any): void;
168
203
  getAll(): RouteInfo[];
169
204
  getByMethod(method: string): RouteInfo[];