|
1 | 1 | import { EventEmitter } from 'events'; |
2 | 2 | import * as Schematic from '../api/types'; |
3 | 3 | import { DatastreamWSClient } from './websocket-client'; |
4 | | -import { DataStreamResp, DataStreamReq, EntityType, MessageType } from './types'; |
| 4 | +import { DataStreamResp, DataStreamReq, DataStreamError, EntityType, MessageType } from './types'; |
5 | 5 | import { RulesEngineClient } from '../rules-engine'; |
6 | 6 | import { Logger } from '../logger'; |
7 | 7 |
|
@@ -44,7 +44,6 @@ export interface DataStreamClientOptions { |
44 | 44 | type PendingRequestHandler<T> = (value: T | null) => void; |
45 | 45 |
|
46 | 46 | // Cache key constants |
47 | | -const CACHE_KEY_PREFIX = 'schematic'; |
48 | 47 | const CACHE_KEY_PREFIX_COMPANY = 'company'; |
49 | 48 | const CACHE_KEY_PREFIX_USER = 'user'; |
50 | 49 | const CACHE_KEY_PREFIX_FLAGS = 'flags'; |
@@ -796,7 +795,7 @@ export class DataStreamClient extends EventEmitter { |
796 | 795 | * handleErrorMessage processes error messages |
797 | 796 | */ |
798 | 797 | private async handleErrorMessage(message: DataStreamResp): Promise<void> { |
799 | | - const errorData = message.data as any; |
| 798 | + const errorData = message.data as DataStreamError; |
800 | 799 |
|
801 | 800 | if (errorData?.keys && errorData?.entity_type) { |
802 | 801 | // Notify pending requests with null/error |
@@ -1146,28 +1145,28 @@ export class DataStreamClient extends EventEmitter { |
1146 | 1145 | } |
1147 | 1146 |
|
1148 | 1147 | /** |
1149 | | - * evaluateFlag evaluates a flag using the rules engine |
| 1148 | + * sanitizeForWasm removes null/undefined values from objects for WASM compatibility |
1150 | 1149 | */ |
1151 | | - private sanitizeForWasm(obj: any): any { |
| 1150 | + private sanitizeForWasm<T>(obj: T): T { |
1152 | 1151 | if (obj === null || obj === undefined) { |
1153 | | - return null; |
| 1152 | + return null as T; |
1154 | 1153 | } |
1155 | | - |
| 1154 | + |
1156 | 1155 | if (Array.isArray(obj)) { |
1157 | | - return obj.map(item => this.sanitizeForWasm(item)).filter(item => item !== null); |
| 1156 | + return obj.map(item => this.sanitizeForWasm(item)).filter(item => item !== null) as T; |
1158 | 1157 | } |
1159 | | - |
| 1158 | + |
1160 | 1159 | if (typeof obj === 'object') { |
1161 | | - const sanitized: any = {}; |
| 1160 | + const sanitized: Record<string, unknown> = {}; |
1162 | 1161 | for (const [key, value] of Object.entries(obj)) { |
1163 | 1162 | const sanitizedValue = this.sanitizeForWasm(value); |
1164 | 1163 | if (sanitizedValue !== null) { |
1165 | 1164 | sanitized[key] = sanitizedValue; |
1166 | 1165 | } |
1167 | 1166 | } |
1168 | | - return sanitized; |
| 1167 | + return sanitized as T; |
1169 | 1168 | } |
1170 | | - |
| 1169 | + |
1171 | 1170 | return obj; |
1172 | 1171 | } |
1173 | 1172 |
|
|
0 commit comments