@almadar/server 2.0.0 → 2.0.2
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/dist/deepagent/__tests__/memory.test.d.ts +6 -0
- package/dist/deepagent/__tests__/memory.test.d.ts.map +1 -0
- package/dist/deepagent/__tests__/session.test.d.ts +6 -0
- package/dist/deepagent/__tests__/session.test.d.ts.map +1 -0
- package/dist/deepagent/__tests__/skill-agent.test.d.ts +6 -0
- package/dist/deepagent/__tests__/skill-agent.test.d.ts.map +1 -0
- package/dist/deepagent/memory.d.ts +17 -0
- package/dist/deepagent/memory.d.ts.map +1 -0
- package/dist/deepagent/session.d.ts +17 -0
- package/dist/deepagent/session.d.ts.map +1 -0
- package/dist/deepagent/skill-agent.d.ts +22 -0
- package/dist/deepagent/skill-agent.d.ts.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -19
- package/dist/index.js.map +1 -1
- package/dist/lib/db.d.ts +36 -0
- package/dist/lib/db.d.ts.map +1 -0
- package/dist/lib/debugRouter.d.ts +20 -0
- package/dist/lib/debugRouter.d.ts.map +1 -0
- package/dist/lib/env.d.ts +16 -0
- package/dist/lib/env.d.ts.map +1 -0
- package/dist/lib/eventBus.d.ts +44 -0
- package/dist/lib/eventBus.d.ts.map +1 -0
- package/dist/lib/eventBusTransport.d.ts +143 -0
- package/dist/lib/eventBusTransport.d.ts.map +1 -0
- package/dist/lib/eventPersistence.d.ts +151 -0
- package/dist/lib/eventPersistence.d.ts.map +1 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +17 -7
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/logger.d.ts +7 -0
- package/dist/lib/logger.d.ts.map +1 -0
- package/dist/lib/serviceDiscovery.d.ts +168 -0
- package/dist/lib/serviceDiscovery.d.ts.map +1 -0
- package/dist/lib/websocket.d.ts +41 -0
- package/dist/lib/websocket.d.ts.map +1 -0
- package/dist/middleware/__tests__/multi-user.test.d.ts +6 -0
- package/dist/middleware/__tests__/multi-user.test.d.ts.map +1 -0
- package/dist/middleware/authenticateFirebase.d.ts +4 -0
- package/dist/middleware/authenticateFirebase.d.ts.map +1 -0
- package/dist/middleware/errorHandler.d.ts +53 -0
- package/dist/middleware/errorHandler.d.ts.map +1 -0
- package/dist/middleware/index.d.ts +4 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/multi-user.d.ts +34 -0
- package/dist/middleware/multi-user.d.ts.map +1 -0
- package/dist/middleware/validation.d.ts +15 -0
- package/dist/middleware/validation.d.ts.map +1 -0
- package/dist/routes/__tests__/observability.test.d.ts +6 -0
- package/dist/routes/__tests__/observability.test.d.ts.map +1 -0
- package/dist/routes/observability.d.ts +10 -0
- package/dist/routes/observability.d.ts.map +1 -0
- package/dist/services/DataService.d.ts +66 -0
- package/dist/services/DataService.d.ts.map +1 -0
- package/dist/services/MockDataService.d.ts +110 -0
- package/dist/services/MockDataService.d.ts.map +1 -0
- package/dist/services/index.d.ts +8 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +29 -10
- package/dist/services/index.js.map +1 -1
- package/dist/stores/ChangeSetStore.d.ts +24 -0
- package/dist/stores/ChangeSetStore.d.ts.map +1 -0
- package/dist/stores/SchemaProtectionService.d.ts +23 -0
- package/dist/stores/SchemaProtectionService.d.ts.map +1 -0
- package/dist/stores/SchemaStore.d.ts +52 -0
- package/dist/stores/SchemaStore.d.ts.map +1 -0
- package/dist/stores/SnapshotStore.d.ts +26 -0
- package/dist/stores/SnapshotStore.d.ts.map +1 -0
- package/dist/stores/ValidationStore.d.ts +19 -0
- package/dist/stores/ValidationStore.d.ts.map +1 -0
- package/dist/stores/firestoreFormat.d.ts +21 -0
- package/dist/stores/firestoreFormat.d.ts.map +1 -0
- package/dist/stores/index.d.ts +14 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/queryFilters.d.ts +77 -0
- package/dist/utils/queryFilters.d.ts.map +1 -0
- package/dist/websocket/__tests__/state-sync.test.d.ts +6 -0
- package/dist/websocket/__tests__/state-sync.test.d.ts.map +1 -0
- package/dist/websocket/state-sync.d.ts +39 -0
- package/dist/websocket/state-sync.d.ts.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service Discovery — Registry for service orbital instances
|
|
3
|
+
*
|
|
4
|
+
* Enables distributed event routing by tracking which services are running,
|
|
5
|
+
* what events they emit/listen for, and where they can be reached.
|
|
6
|
+
*
|
|
7
|
+
* Supports:
|
|
8
|
+
* - In-memory registry (default, single-process)
|
|
9
|
+
* - Registration/deregistration with heartbeat
|
|
10
|
+
* - Event routing: find services that listen for a given event
|
|
11
|
+
* - Health tracking via TTL-based expiry
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
/** Service registration record */
|
|
16
|
+
export interface ServiceRegistration {
|
|
17
|
+
/** Service name (from .orb schema name) */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Unique instance ID */
|
|
20
|
+
instanceId: string;
|
|
21
|
+
/** Host where the service is running */
|
|
22
|
+
host: string;
|
|
23
|
+
/** Port number */
|
|
24
|
+
port: number;
|
|
25
|
+
/** Hash of the .orb schema for version tracking */
|
|
26
|
+
orbHash: string;
|
|
27
|
+
/** Events this service emits */
|
|
28
|
+
emits: string[];
|
|
29
|
+
/** Events this service listens for */
|
|
30
|
+
listens: string[];
|
|
31
|
+
/** Registration timestamp */
|
|
32
|
+
registeredAt: number;
|
|
33
|
+
/** Last heartbeat timestamp */
|
|
34
|
+
lastHeartbeat: number;
|
|
35
|
+
/** Service status */
|
|
36
|
+
status: 'starting' | 'ready' | 'degraded' | 'stopping';
|
|
37
|
+
/** Optional metadata */
|
|
38
|
+
metadata?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
/** Options for the service registry */
|
|
41
|
+
export interface ServiceRegistryOptions {
|
|
42
|
+
/** TTL for service registrations in ms (default: 60000) */
|
|
43
|
+
heartbeatTtlMs?: number;
|
|
44
|
+
/** Cleanup interval for expired registrations (default: 30000) */
|
|
45
|
+
cleanupIntervalMs?: number;
|
|
46
|
+
}
|
|
47
|
+
/** Service registry interface for pluggable backends */
|
|
48
|
+
export interface IServiceRegistry {
|
|
49
|
+
/** Register a service */
|
|
50
|
+
register(service: ServiceRegistration): Promise<void>;
|
|
51
|
+
/** Deregister a service */
|
|
52
|
+
deregister(instanceId: string): Promise<void>;
|
|
53
|
+
/** Update heartbeat for a service */
|
|
54
|
+
heartbeat(instanceId: string): Promise<void>;
|
|
55
|
+
/** Update service status */
|
|
56
|
+
updateStatus(instanceId: string, status: ServiceRegistration['status']): Promise<void>;
|
|
57
|
+
/** Get all registered services */
|
|
58
|
+
getAll(): Promise<ServiceRegistration[]>;
|
|
59
|
+
/** Get services by name */
|
|
60
|
+
getByName(name: string): Promise<ServiceRegistration[]>;
|
|
61
|
+
/** Find services that listen for a given event */
|
|
62
|
+
findListeners(event: string): Promise<ServiceRegistration[]>;
|
|
63
|
+
/** Find services that emit a given event */
|
|
64
|
+
findEmitters(event: string): Promise<ServiceRegistration[]>;
|
|
65
|
+
/** Remove expired registrations */
|
|
66
|
+
cleanup(ttlMs: number): Promise<number>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* In-memory service registry for single-process and development mode.
|
|
70
|
+
*/
|
|
71
|
+
export declare class InMemoryServiceRegistry implements IServiceRegistry {
|
|
72
|
+
private services;
|
|
73
|
+
register(service: ServiceRegistration): Promise<void>;
|
|
74
|
+
deregister(instanceId: string): Promise<void>;
|
|
75
|
+
heartbeat(instanceId: string): Promise<void>;
|
|
76
|
+
updateStatus(instanceId: string, status: ServiceRegistration['status']): Promise<void>;
|
|
77
|
+
getAll(): Promise<ServiceRegistration[]>;
|
|
78
|
+
getByName(name: string): Promise<ServiceRegistration[]>;
|
|
79
|
+
findListeners(event: string): Promise<ServiceRegistration[]>;
|
|
80
|
+
findEmitters(event: string): Promise<ServiceRegistration[]>;
|
|
81
|
+
cleanup(ttlMs: number): Promise<number>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Service discovery manager that wraps a registry backend.
|
|
85
|
+
*
|
|
86
|
+
* Usage:
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const discovery = new ServiceDiscovery();
|
|
89
|
+
* discovery.startCleanup();
|
|
90
|
+
*
|
|
91
|
+
* // Register a service
|
|
92
|
+
* await discovery.register({
|
|
93
|
+
* name: 'LLMService',
|
|
94
|
+
* instanceId: 'llm-001',
|
|
95
|
+
* host: 'localhost',
|
|
96
|
+
* port: 3001,
|
|
97
|
+
* orbHash: 'abc123',
|
|
98
|
+
* emits: ['LLM_RESPONSE', 'LLM_READY'],
|
|
99
|
+
* listens: ['AGENT_LLM_REQUEST'],
|
|
100
|
+
* });
|
|
101
|
+
*
|
|
102
|
+
* // Find who can handle an event
|
|
103
|
+
* const listeners = await discovery.findListeners('AGENT_LLM_REQUEST');
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare class ServiceDiscovery {
|
|
107
|
+
private registry;
|
|
108
|
+
private options;
|
|
109
|
+
private cleanupTimer;
|
|
110
|
+
constructor(options?: ServiceRegistryOptions, registry?: IServiceRegistry);
|
|
111
|
+
/**
|
|
112
|
+
* Register a service with the registry.
|
|
113
|
+
*/
|
|
114
|
+
register(service: Omit<ServiceRegistration, 'registeredAt' | 'lastHeartbeat' | 'status'> & {
|
|
115
|
+
status?: ServiceRegistration['status'];
|
|
116
|
+
}): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Deregister a service.
|
|
119
|
+
*/
|
|
120
|
+
deregister(instanceId: string): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Send heartbeat for a service.
|
|
123
|
+
*/
|
|
124
|
+
heartbeat(instanceId: string): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Mark a service as ready.
|
|
127
|
+
*/
|
|
128
|
+
markReady(instanceId: string): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* Mark a service as degraded.
|
|
131
|
+
*/
|
|
132
|
+
markDegraded(instanceId: string): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Find all services that listen for a given event.
|
|
135
|
+
*/
|
|
136
|
+
findListeners(event: string): Promise<ServiceRegistration[]>;
|
|
137
|
+
/**
|
|
138
|
+
* Find all services that emit a given event.
|
|
139
|
+
*/
|
|
140
|
+
findEmitters(event: string): Promise<ServiceRegistration[]>;
|
|
141
|
+
/**
|
|
142
|
+
* Get all registered services.
|
|
143
|
+
*/
|
|
144
|
+
getAll(): Promise<ServiceRegistration[]>;
|
|
145
|
+
/**
|
|
146
|
+
* Get the full event topology (who emits what, who listens for what).
|
|
147
|
+
*/
|
|
148
|
+
getEventTopology(): Promise<{
|
|
149
|
+
events: Array<{
|
|
150
|
+
event: string;
|
|
151
|
+
emitters: string[];
|
|
152
|
+
listeners: string[];
|
|
153
|
+
}>;
|
|
154
|
+
}>;
|
|
155
|
+
/**
|
|
156
|
+
* Start periodic cleanup of expired services.
|
|
157
|
+
*/
|
|
158
|
+
startCleanup(): void;
|
|
159
|
+
/**
|
|
160
|
+
* Stop periodic cleanup.
|
|
161
|
+
*/
|
|
162
|
+
stopCleanup(): void;
|
|
163
|
+
/**
|
|
164
|
+
* Get the underlying registry (for testing).
|
|
165
|
+
*/
|
|
166
|
+
getRegistry(): IServiceRegistry;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=serviceDiscovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceDiscovery.d.ts","sourceRoot":"","sources":["../../src/lib/serviceDiscovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,kCAAkC;AAClC,MAAM,WAAW,mBAAmB;IA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}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket Event Broadcast - Cross-client event synchronization
|
|
3
|
+
*
|
|
4
|
+
* Broadcasts server-side events to all connected clients via WebSocket.
|
|
5
|
+
* This enables real-time updates across multiple browser clients.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { WebSocketServer } from 'ws';
|
|
10
|
+
import type { Server } from 'http';
|
|
11
|
+
/**
|
|
12
|
+
* Setup WebSocket server for event broadcasting.
|
|
13
|
+
*
|
|
14
|
+
* Listens to all server events via wildcard and broadcasts to connected clients.
|
|
15
|
+
*
|
|
16
|
+
* @param server - HTTP server to attach WebSocket to
|
|
17
|
+
* @param path - WebSocket endpoint path (default: '/ws/events')
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { createServer } from 'http';
|
|
22
|
+
* import { setupEventBroadcast } from '@/lib/websocket';
|
|
23
|
+
*
|
|
24
|
+
* const server = createServer(app);
|
|
25
|
+
* setupEventBroadcast(server);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function setupEventBroadcast(server: Server, path?: string): WebSocketServer;
|
|
29
|
+
/**
|
|
30
|
+
* Get the WebSocket server instance (for testing or advanced usage)
|
|
31
|
+
*/
|
|
32
|
+
export declare function getWebSocketServer(): WebSocketServer | null;
|
|
33
|
+
/**
|
|
34
|
+
* Close the WebSocket server
|
|
35
|
+
*/
|
|
36
|
+
export declare function closeWebSocketServer(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Get connected client count
|
|
39
|
+
*/
|
|
40
|
+
export declare function getConnectedClientCount(): number;
|
|
41
|
+
//# sourceMappingURL=websocket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../src/lib/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAA2B,MAAM,IAAI,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAmB,MAAM,MAAM,CAAC;AAmBpD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,MAAqB,GAAG,eAAe,CA8EhG;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,GAAG,IAAI,CAE3D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAgBpD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAGhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-user.test.d.ts","sourceRoot":"","sources":["../../../src/middleware/__tests__/multi-user.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NextFunction, Request, Response } from 'express';
|
|
2
|
+
export declare function authenticateFirebase(req: Request, res: Response, next: NextFunction): Promise<void | Response<any, Record<string, any>>>;
|
|
3
|
+
export default authenticateFirebase;
|
|
4
|
+
//# sourceMappingURL=authenticateFirebase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticateFirebase.d.ts","sourceRoot":"","sources":["../../src/middleware/authenticateFirebase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAwB1D,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,sDA0BzF;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Base application error class
|
|
4
|
+
*/
|
|
5
|
+
export declare class AppError extends Error {
|
|
6
|
+
statusCode: number;
|
|
7
|
+
message: string;
|
|
8
|
+
code?: string | undefined;
|
|
9
|
+
constructor(statusCode: number, message: string, code?: string | undefined);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 404 Not Found error
|
|
13
|
+
*/
|
|
14
|
+
export declare class NotFoundError extends AppError {
|
|
15
|
+
constructor(message?: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 400 Bad Request / Validation error
|
|
19
|
+
*/
|
|
20
|
+
export declare class ValidationError extends AppError {
|
|
21
|
+
constructor(message?: string);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 401 Unauthorized error
|
|
25
|
+
*/
|
|
26
|
+
export declare class UnauthorizedError extends AppError {
|
|
27
|
+
constructor(message?: string);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 403 Forbidden error
|
|
31
|
+
*/
|
|
32
|
+
export declare class ForbiddenError extends AppError {
|
|
33
|
+
constructor(message?: string);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 409 Conflict error
|
|
37
|
+
*/
|
|
38
|
+
export declare class ConflictError extends AppError {
|
|
39
|
+
constructor(message?: string);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Global error handler middleware
|
|
43
|
+
*/
|
|
44
|
+
export declare const errorHandler: (err: Error, _req: Request, res: Response, _next: NextFunction) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Async handler wrapper to catch errors in async route handlers
|
|
47
|
+
*/
|
|
48
|
+
export declare const asyncHandler: (fn: (req: Request, res: Response, next: NextFunction) => Promise<unknown>) => (req: Request, res: Response, next: NextFunction) => void;
|
|
49
|
+
/**
|
|
50
|
+
* 404 handler for unmatched routes
|
|
51
|
+
*/
|
|
52
|
+
export declare const notFoundHandler: (req: Request, res: Response) => void;
|
|
53
|
+
//# sourceMappingURL=errorHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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
|
+
export { errorHandler, notFoundHandler, asyncHandler, AppError, NotFoundError, ValidationError, UnauthorizedError, ForbiddenError, ConflictError, } from './errorHandler';
|
|
2
|
+
export { validateBody, validateQuery, validateParams } from './validation';
|
|
3
|
+
export { authenticateFirebase } from './authenticateFirebase.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,aAAa,GACd,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-User Middleware
|
|
3
|
+
*
|
|
4
|
+
* Provides user isolation and session ownership using Firebase Auth.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import type { Request, Response, NextFunction } from 'express';
|
|
9
|
+
declare global {
|
|
10
|
+
namespace Express {
|
|
11
|
+
interface Request {
|
|
12
|
+
user?: {
|
|
13
|
+
uid: string;
|
|
14
|
+
email?: string;
|
|
15
|
+
roles?: string[];
|
|
16
|
+
orgId?: string;
|
|
17
|
+
};
|
|
18
|
+
userContext?: {
|
|
19
|
+
userId: string;
|
|
20
|
+
orgId?: string;
|
|
21
|
+
roles?: string[];
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Middleware to set up user context from Firebase Auth
|
|
28
|
+
*/
|
|
29
|
+
export declare function multiUserMiddleware(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Verify Firebase Auth token from Authorization header
|
|
32
|
+
*/
|
|
33
|
+
export declare function verifyFirebaseAuth(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
34
|
+
//# sourceMappingURL=multi-user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-user.d.ts","sourceRoot":"","sources":["../../src/middleware/multi-user.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG/D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,IAAI,CAAC,EAAE;gBACL,GAAG,EAAE,MAAM,CAAC;gBACZ,KAAK,CAAC,EAAE,MAAM,CAAC;gBACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;gBACjB,KAAK,CAAC,EAAE,MAAM,CAAC;aAChB,CAAC;YACF,WAAW,CAAC,EAAE;gBACZ,MAAM,EAAE,MAAM,CAAC;gBACf,KAAK,CAAC,EAAE,MAAM,CAAC;gBACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;aAClB,CAAC;SACH;KACF;CACF;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,IAAI,CAAC,CA4Bf;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
import { AnyZodObject } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Middleware to validate request body against a Zod schema
|
|
5
|
+
*/
|
|
6
|
+
export declare const validateBody: (schema: AnyZodObject) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Middleware to validate request query parameters against a Zod schema
|
|
9
|
+
*/
|
|
10
|
+
export declare const validateQuery: (schema: AnyZodObject) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Middleware to validate request params against a Zod schema
|
|
13
|
+
*/
|
|
14
|
+
export declare const validateParams: (schema: AnyZodObject) => (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
15
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/middleware/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAY,MAAM,KAAK,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,YAAY,GACtB,QAAQ,YAAY,MAAY,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,KAAG,OAAO,CAAC,IAAI,CAmB9F,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,aAAa,GACvB,QAAQ,YAAY,MAAY,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,KAAG,OAAO,CAAC,IAAI,CAmB9F,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,cAAc,GACxB,QAAQ,YAAY,MAAY,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,KAAG,OAAO,CAAC,IAAI,CAmB9F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observability.test.d.ts","sourceRoot":"","sources":["../../../src/routes/__tests__/observability.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Observability Routes
|
|
3
|
+
*
|
|
4
|
+
* Provides endpoints for metrics, health checks, and telemetry.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
declare const router: import("express-serve-static-core").Router;
|
|
9
|
+
export default router;
|
|
10
|
+
//# sourceMappingURL=observability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observability.d.ts","sourceRoot":"","sources":["../../src/routes/observability.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,QAAA,MAAM,MAAM,4CAAW,CAAC;AAyExB,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataService - Unified data access abstraction
|
|
3
|
+
*
|
|
4
|
+
* Provides a common interface for data operations that can be backed by
|
|
5
|
+
* either MockDataService (for development) or Firebase (for production).
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { type FieldSchema } from './MockDataService.js';
|
|
10
|
+
import { type ParsedFilter } from '../utils/queryFilters.js';
|
|
11
|
+
interface BaseEntity {
|
|
12
|
+
id: string;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Pagination options for list queries
|
|
18
|
+
*/
|
|
19
|
+
export interface PaginationOptions {
|
|
20
|
+
/** Page number (1-indexed) */
|
|
21
|
+
page?: number;
|
|
22
|
+
/** Number of items per page */
|
|
23
|
+
pageSize?: number;
|
|
24
|
+
/** Search term to filter results */
|
|
25
|
+
search?: string;
|
|
26
|
+
/** Fields to search in (defaults to all string fields) */
|
|
27
|
+
searchFields?: string[];
|
|
28
|
+
/** Sort field */
|
|
29
|
+
sortBy?: string;
|
|
30
|
+
/** Sort direction */
|
|
31
|
+
sortOrder?: 'asc' | 'desc';
|
|
32
|
+
/** Filters parsed from query params */
|
|
33
|
+
filters?: ParsedFilter[];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Paginated response structure
|
|
37
|
+
*/
|
|
38
|
+
export interface PaginatedResult<T> {
|
|
39
|
+
data: T[];
|
|
40
|
+
total: number;
|
|
41
|
+
page: number;
|
|
42
|
+
pageSize: number;
|
|
43
|
+
totalPages: number;
|
|
44
|
+
}
|
|
45
|
+
export interface DataService {
|
|
46
|
+
list<T>(collection: string): Promise<T[]>;
|
|
47
|
+
listPaginated<T>(collection: string, options?: PaginationOptions): Promise<PaginatedResult<T>>;
|
|
48
|
+
getById<T>(collection: string, id: string): Promise<T | null>;
|
|
49
|
+
create<T extends BaseEntity>(collection: string, data: Partial<T>): Promise<T>;
|
|
50
|
+
update<T extends BaseEntity>(collection: string, id: string, data: Partial<T>): Promise<T | null>;
|
|
51
|
+
delete(collection: string, id: string): Promise<boolean>;
|
|
52
|
+
}
|
|
53
|
+
export declare function getDataService(): DataService;
|
|
54
|
+
export declare function resetDataService(): void;
|
|
55
|
+
export interface EntitySeedConfig {
|
|
56
|
+
name: string;
|
|
57
|
+
fields: FieldSchema[];
|
|
58
|
+
seedCount: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Seed mock data for multiple entities.
|
|
62
|
+
* Only works when USE_MOCK_DATA is enabled.
|
|
63
|
+
*/
|
|
64
|
+
export declare function seedMockData(entities: EntitySeedConfig[]): void;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=DataService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataService.d.ts","sourceRoot":"","sources":["../../src/services/DataService.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAMlC,UAAU,UAAU;IAClB,EAAE,EAAE,MA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,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAClG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1D;AAkTD,wBAAgB,cAAc,IAAI,WAAW,CAK5C;AAED,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAMD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAa/D"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MockDataService - In-memory data store with faker-based mock generation
|
|
3
|
+
*
|
|
4
|
+
* Provides a stateful mock data layer that supports all CRUD operations.
|
|
5
|
+
* Uses @faker-js/faker for realistic data generation based on field types.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export interface FieldSchema {
|
|
10
|
+
name: string;
|
|
11
|
+
type: 'string' | 'number' | 'boolean' | 'date' | 'enum' | 'relation' | 'array';
|
|
12
|
+
required?: boolean;
|
|
13
|
+
enumValues?: string[];
|
|
14
|
+
min?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
fakerMethod?: string;
|
|
17
|
+
relatedEntity?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface EntitySchema {
|
|
20
|
+
fields: FieldSchema[];
|
|
21
|
+
seedCount?: number;
|
|
22
|
+
}
|
|
23
|
+
interface BaseEntity {
|
|
24
|
+
id: string;
|
|
25
|
+
createdAt: Date;
|
|
26
|
+
updatedAt: Date;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* In-memory mock data store with CRUD operations and faker-based seeding.
|
|
30
|
+
*/
|
|
31
|
+
export declare class MockDataService {
|
|
32
|
+
private stores;
|
|
33
|
+
private schemas;
|
|
34
|
+
private idCounters;
|
|
35
|
+
constructor();
|
|
36
|
+
/**
|
|
37
|
+
* Initialize store for an entity.
|
|
38
|
+
*/
|
|
39
|
+
private getStore;
|
|
40
|
+
/**
|
|
41
|
+
* Generate next ID for an entity.
|
|
42
|
+
*/
|
|
43
|
+
private nextId;
|
|
44
|
+
/**
|
|
45
|
+
* Register an entity schema.
|
|
46
|
+
*/
|
|
47
|
+
registerSchema(entityName: string, schema: EntitySchema): void;
|
|
48
|
+
/**
|
|
49
|
+
* Seed an entity with mock data.
|
|
50
|
+
*/
|
|
51
|
+
seed(entityName: string, fields: FieldSchema[], count?: number): void;
|
|
52
|
+
/**
|
|
53
|
+
* Generate a single mock item based on field schemas.
|
|
54
|
+
*/
|
|
55
|
+
private generateMockItem;
|
|
56
|
+
/**
|
|
57
|
+
* Generate a mock value for a field based on its schema.
|
|
58
|
+
*/
|
|
59
|
+
private generateFieldValue;
|
|
60
|
+
/**
|
|
61
|
+
* Generate a string value based on field name heuristics.
|
|
62
|
+
* Generic name/title fields use entity-aware format (e.g., "Project Name 1").
|
|
63
|
+
* Specific fields (email, phone, etc.) use faker.
|
|
64
|
+
*/
|
|
65
|
+
private generateStringValue;
|
|
66
|
+
/**
|
|
67
|
+
* Capitalize first letter of a string.
|
|
68
|
+
*/
|
|
69
|
+
private capitalizeFirst;
|
|
70
|
+
/**
|
|
71
|
+
* Generate a date value based on field name heuristics.
|
|
72
|
+
*/
|
|
73
|
+
private generateDateValue;
|
|
74
|
+
/**
|
|
75
|
+
* List all items of an entity.
|
|
76
|
+
*/
|
|
77
|
+
list<T>(entityName: string): T[];
|
|
78
|
+
/**
|
|
79
|
+
* Get a single item by ID.
|
|
80
|
+
*/
|
|
81
|
+
getById<T>(entityName: string, id: string): T | null;
|
|
82
|
+
/**
|
|
83
|
+
* Create a new item.
|
|
84
|
+
*/
|
|
85
|
+
create<T extends BaseEntity>(entityName: string, data: Partial<T>): T;
|
|
86
|
+
/**
|
|
87
|
+
* Update an existing item.
|
|
88
|
+
*/
|
|
89
|
+
update<T extends BaseEntity>(entityName: string, id: string, data: Partial<T>): T | null;
|
|
90
|
+
/**
|
|
91
|
+
* Delete an item.
|
|
92
|
+
*/
|
|
93
|
+
delete(entityName: string, id: string): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Clear all data for an entity.
|
|
96
|
+
*/
|
|
97
|
+
clear(entityName: string): void;
|
|
98
|
+
/**
|
|
99
|
+
* Clear all data.
|
|
100
|
+
*/
|
|
101
|
+
clearAll(): void;
|
|
102
|
+
/**
|
|
103
|
+
* Get count of items for an entity.
|
|
104
|
+
*/
|
|
105
|
+
count(entityName: string): number;
|
|
106
|
+
}
|
|
107
|
+
export declare function getMockDataService(): MockDataService;
|
|
108
|
+
export declare function resetMockDataService(): void;
|
|
109
|
+
export {};
|
|
110
|
+
//# sourceMappingURL=MockDataService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockDataService.d.ts","sourceRoot":"","sources":["../../src/services/MockDataService.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,YAA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,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI;IAmBxF;;OAEG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO;IAa/C;;OAEG;IACH,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAM/B;;OAEG;IACH,QAAQ,IAAI,IAAI;IAKhB;;OAEG;IACH,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;CAIlC;AAKD,wBAAgB,kBAAkB,IAAI,eAAe,CAKpD;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAG3C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Services barrel export
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { MockDataService, getMockDataService, resetMockDataService, type FieldSchema, type EntitySchema } from './MockDataService.js';
|
|
7
|
+
export { getDataService, resetDataService, seedMockData, type DataService, type EntitySeedConfig } from './DataService.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACtI,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|