Skip to content

Commit 4de206f

Browse files
committed
fix: resolve all type checking and linting errors
Fixed type errors and linting configuration: **Type Fixes:** - MultiContextPrintStateMonitor: Added EventEmitter with event forwarding - MultiContextNotificationCoordinator: Fixed printer name access (Name not printerName) - SpoolmanIntegrationService: Made PrinterBackendManager optional with stub - CameraProxyService: Fixed unused parameter (prefixed with _) - config.ts: Fixed type assertion for port number assignment - Added error.utils.ts for error handling utilities **Event System:** - MultiContextPrintStateMonitor now extends EventEmitter and forwards events - Added proper event filtering for null jobName values - Type-safe event maps for all coordinators **Linting:** - Renamed eslint.config.js to .mjs for ES module support - Added Node.js globals configuration - Installed globals and typescript-eslint packages - Fixed RtspStreamService require() eslint directive **Result:** - ✅ Type check: PASSING (npm run type-check) - ✅ Lint: PASSING with 0 errors, 9 warnings (all intentional any types)
1 parent 9a4e95d commit 4de206f

11 files changed

Lines changed: 530 additions & 71 deletions

eslint.config.js

Lines changed: 0 additions & 43 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// @ts-check
2+
import eslint from '@eslint/js';
3+
import tseslint from 'typescript-eslint';
4+
import globals from 'globals';
5+
6+
export default tseslint.config(
7+
eslint.configs.recommended,
8+
...tseslint.configs.recommended,
9+
{
10+
files: ['**/*.ts', '**/*.tsx'],
11+
languageOptions: {
12+
ecmaVersion: 2022,
13+
sourceType: 'module',
14+
globals: {
15+
...globals.node,
16+
},
17+
parserOptions: {
18+
project: './tsconfig.json',
19+
},
20+
},
21+
rules: {
22+
'@typescript-eslint/no-explicit-any': 'warn',
23+
'@typescript-eslint/no-unused-vars': [
24+
'error',
25+
{
26+
argsIgnorePattern: '^_',
27+
varsIgnorePattern: '^_',
28+
},
29+
],
30+
},
31+
},
32+
{
33+
ignores: ['dist/**', 'node_modules/**', '.dependencies/**'],
34+
}
35+
);

package-lock.json

Lines changed: 43 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@
3838
"author": "Parallel-7",
3939
"license": "MIT",
4040
"dependencies": {
41+
"@cycjimmy/jsmpeg-player": "^6.1.2",
4142
"@ghosttypes/ff-api": "file:.dependencies/ff-5mp-api-ts-1.0.0",
4243
"@parallel-7/slicer-meta": "file:.dependencies/slicer-meta-1.1.0",
43-
"express": "^5.1.0",
44-
"ws": "^8.18.3",
4544
"axios": "^1.8.4",
46-
"zod": "^4.0.5",
45+
"express": "^5.1.0",
46+
"form-data": "^4.0.0",
4747
"gridstack": "^12.3.3",
4848
"lucide": "^0.552.0",
49-
"@cycjimmy/jsmpeg-player": "^6.1.2",
5049
"node-rtsp-stream": "^0.0.9",
51-
"form-data": "^4.0.0"
50+
"ws": "^8.18.3",
51+
"zod": "^4.0.5"
5252
},
5353
"devDependencies": {
5454
"@types/express": "^4.17.21",
@@ -58,9 +58,11 @@
5858
"@typescript-eslint/parser": "^8.14.0",
5959
"concurrently": "^9.1.2",
6060
"eslint": "^9.16.0",
61-
"typescript": "^5.7.2",
61+
"globals": "^16.5.0",
62+
"pkg": "^5.8.1",
6263
"rimraf": "^6.0.1",
63-
"pkg": "^5.8.1"
64+
"typescript": "^5.7.2",
65+
"typescript-eslint": "^8.47.0"
6466
},
6567
"engines": {
6668
"node": ">=20.0.0"

src/services/CameraProxyService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class CameraProxyService extends EventEmitter<CameraProxyEventMap> {
210210
});
211211

212212
// Set up health check endpoint
213-
app.get('/health', (req, res) => {
213+
app.get('/health', (_req, res) => {
214214
const streamInfo = this.contextStreams.get(contextId);
215215
res.json({
216216
contextId,

src/services/MultiContextNotificationCoordinator.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
import { EventEmitter } from '../utils/EventEmitter';
3737
import { getMultiContextPrintStateMonitor } from './MultiContextPrintStateMonitor';
38+
import { getPrinterContextManager } from '../managers/PrinterContextManager';
3839
import type { PrinterStatus } from '../types/polling';
3940

4041
// ============================================================================
@@ -129,7 +130,10 @@ export class MultiContextNotificationCoordinator extends EventEmitter<Notificati
129130
completedAt?: Date;
130131
}
131132
): void {
132-
const printerName = event.status.printerInfo.printerName || 'Unknown Printer';
133+
// Get printer name from context
134+
const contextManager = getPrinterContextManager();
135+
const context = contextManager.getContext(event.contextId);
136+
const printerName = context?.printerDetails?.Name || 'Unknown Printer';
133137

134138
const notification: PrintNotificationEvent = {
135139
type,

src/services/MultiContextPrintStateMonitor.ts

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,59 @@
55
* each printer connection has its own isolated state monitoring instance.
66
*/
77

8+
import { EventEmitter } from '../utils/EventEmitter';
89
import { PrintStateMonitor } from './PrintStateMonitor';
910
import type { PrinterPollingService } from './PrinterPollingService';
11+
import type { PrinterStatus } from '../types/polling';
12+
13+
/**
14+
* Event map for MultiContextPrintStateMonitor
15+
*/
16+
interface MultiContextPrintStateMonitorEventMap extends Record<string, unknown[]> {
17+
'state-changed': [{
18+
contextId: string;
19+
previousState: string;
20+
currentState: string;
21+
status: PrinterStatus;
22+
timestamp: Date;
23+
}];
24+
'print-started': [{
25+
contextId: string;
26+
jobName: string;
27+
status: PrinterStatus;
28+
timestamp: Date;
29+
}];
30+
'print-completed': [{
31+
contextId: string;
32+
jobName: string;
33+
status: PrinterStatus;
34+
completedAt: Date;
35+
}];
36+
'print-cancelled': [{
37+
contextId: string;
38+
jobName: string;
39+
status: PrinterStatus;
40+
timestamp: Date;
41+
}];
42+
'print-error': [{
43+
contextId: string;
44+
jobName: string;
45+
status: PrinterStatus;
46+
timestamp: Date;
47+
}];
48+
}
1049

1150
/**
1251
* Multi-context coordinator for print state monitoring
13-
* Manages per-context PrintStateMonitor instances
52+
* Manages per-context PrintStateMonitor instances and forwards their events
1453
*/
15-
export class MultiContextPrintStateMonitor {
54+
export class MultiContextPrintStateMonitor extends EventEmitter<MultiContextPrintStateMonitorEventMap> {
1655
private readonly monitors: Map<string, PrintStateMonitor> = new Map();
1756

57+
constructor() {
58+
super();
59+
}
60+
1861
/**
1962
* Create a print state monitor for a specific context
2063
*/
@@ -32,12 +75,52 @@ export class MultiContextPrintStateMonitor {
3275
const monitor = new PrintStateMonitor(contextId);
3376
monitor.setPollingService(pollingService);
3477

78+
// Forward events from this monitor
79+
this.setupEventForwarding(monitor);
80+
3581
// Store monitor
3682
this.monitors.set(contextId, monitor);
3783

3884
console.log(`[MultiContextPrintStateMonitor] Created monitor for context ${contextId}`);
3985
}
4086

87+
/**
88+
* Setup event forwarding from individual monitor
89+
*/
90+
private setupEventForwarding(monitor: PrintStateMonitor): void {
91+
monitor.on('state-changed', (event) => {
92+
this.emit('state-changed', event);
93+
});
94+
95+
monitor.on('print-started', (event) => {
96+
// Only forward if we have a job name
97+
if (event.jobName) {
98+
this.emit('print-started', { ...event, jobName: event.jobName });
99+
}
100+
});
101+
102+
monitor.on('print-completed', (event) => {
103+
// Only forward if we have a job name
104+
if (event.jobName) {
105+
this.emit('print-completed', { ...event, jobName: event.jobName });
106+
}
107+
});
108+
109+
monitor.on('print-cancelled', (event) => {
110+
// Only forward if we have a job name
111+
if (event.jobName) {
112+
this.emit('print-cancelled', { ...event, jobName: event.jobName });
113+
}
114+
});
115+
116+
monitor.on('print-error', (event) => {
117+
// Only forward if we have a job name
118+
if (event.jobName) {
119+
this.emit('print-error', { ...event, jobName: event.jobName });
120+
}
121+
});
122+
}
123+
41124
/**
42125
* Get print state monitor for a specific context
43126
*/

src/services/RtspStreamService.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ const execAsync = promisify(exec);
3838

3939
// node-rtsp-stream doesn't have official TypeScript types
4040
// Using dynamic require with type casting
41-
/* eslint-disable @typescript-eslint/no-var-requires */
42-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
43-
/* eslint-disable @typescript-eslint/no-unsafe-call */
44-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
41+
/* eslint-disable @typescript-eslint/no-require-imports */
4542

4643
// Stream type from node-rtsp-stream
4744
interface Stream {

0 commit comments

Comments
 (0)