From 5d6b31de158840acff746b6f566c277fc44e146f Mon Sep 17 00:00:00 2001 From: seb Date: Sun, 1 Nov 2026 00:38:04 +0100 Subject: [PATCH] u --- src/api/agent/index.js | 15 +-------------- src/api/routes/article/media.js | 2 -- src/api/routes/events.js | 1 - src/api/routes/printerjob.js | 12 ------------ src/api/routes/zpljob.js | 3 --- 5 files changed, 1 insertion(+), 32 deletions(-) diff --git a/src/api/agent/index.js b/src/api/agent/index.js index 42f1147..d57d8b0 100644 --- a/src/api/agent/index.js +++ b/src/api/agent/index.js @@ -232,7 +232,6 @@ export function notifyAgentJob(agentId, action, job) { for (const clientRes of conns) { if (!clientRes.writableEnded) { clientRes.write(`event: job\ndata: ${payload}\n\n`); - clientRes.write(`event: printerjob\ndata: ${payload}\n\n`); clientRes.flush?.(); } } @@ -407,14 +406,11 @@ async function handleState(req, res) { if (rawState?.job?.id && rawState?.job?.state) { try { - const updatedJob = await printerjobDb.updateState( + await printerjobDb.updateState( { agentId: req.agent.id }, rawState.job.id, rawState.job.state ); - if (req.agent?.companyId) { - emit('printerjob', { companyId: req.agent.companyId, data: { job: updatedJob } }); - } } catch (jobErr) { log.debug(`Agent reported job state update for ${rawState.job.id}:`, jobErr?.message); } @@ -486,9 +482,6 @@ agentRouter.get('/jobs/:id', agentAuthMiddleware, async (req, res) => { agentRouter.post('/jobs/:id/processing', agentAuthMiddleware, async (req, res) => { try { const job = await printerjobDb.updateState({ agentId: req.agent.id }, req.params.id, 'processing'); - if (req.agent?.companyId) { - emit('printerjob', { companyId: req.agent.companyId, data: { job } }); - } res.status(200).json({ success: true, job }); } catch (err) { if (err.message === 'Printerjob not found') return res.status(404).json({ error: err.message }); @@ -500,9 +493,6 @@ agentRouter.post('/jobs/:id/processing', agentAuthMiddleware, async (req, res) = agentRouter.post('/jobs/:id/completed', agentAuthMiddleware, async (req, res) => { try { const job = await printerjobDb.updateState({ agentId: req.agent.id }, req.params.id, 'completed'); - if (req.agent?.companyId) { - emit('printerjob', { companyId: req.agent.companyId, data: { job } }); - } res.status(200).json({ success: true, job }); } catch (err) { if (err.message === 'Printerjob not found') return res.status(404).json({ error: err.message }); @@ -518,9 +508,6 @@ agentRouter.patch('/jobs/:id', agentAuthMiddleware, async (req, res) => { } try { const job = await printerjobDb.updateState({ agentId: req.agent.id }, req.params.id, state); - if (req.agent?.companyId) { - emit('printerjob', { companyId: req.agent.companyId, data: { job } }); - } res.status(200).json({ success: true, job }); } catch (err) { if (err.message === 'Printerjob not found') return res.status(404).json({ error: err.message }); diff --git a/src/api/routes/article/media.js b/src/api/routes/article/media.js index 92486b4..04d6146 100644 --- a/src/api/routes/article/media.js +++ b/src/api/routes/article/media.js @@ -7,7 +7,6 @@ import * as printerDb from '../../../db/printer.js'; import * as agentprinterDb from '../../../db/agentprinter.js'; import * as labeltemplateDb from '../../../db/labeltemplate.js'; import * as printerjobDb from '../../../db/printerjob.js'; -import { emit } from '../../sse.js'; import { notifyAgentJob } from '../../agent/index.js'; import { pngToZpl } from '../../../services/zplService.js'; import { applyZplCopies } from '../zpljob.js'; @@ -481,7 +480,6 @@ export function register(app, basePath = '') { notifyAgentJob(job.printeragentId, 'created', job); } - emit('printerjob', { companyId, data: { job } }); return res.status(200).json({ success: true, printerjob: job }); } diff --git a/src/api/routes/events.js b/src/api/routes/events.js index 1c13b40..c69196f 100644 --- a/src/api/routes/events.js +++ b/src/api/routes/events.js @@ -57,7 +57,6 @@ export function register(app, basePath = '') { * | `printer` | `{}` | `POST /printer`, `PUT /printer/{id}`, `PATCH /printer/{id}`, `DELETE /printer/{id}` | * | `printeragent` | `{}` | `PUT /printeragent`, `PATCH /printeragent/{id}`, `DELETE /printeragent/{id}`, printer agent connect/disconnect/state | * | `agentprinter` | `{ printers }` or `{}` | `PATCH /agentprinter/{id}`, `PUT /agentprinter/order`, `DELETE /agentprinter/{id}`, agent state updates / printer discovery | - * | `printerjob` | `{ job }` or `{ jobId, state }` | `POST /zpljob`, `POST /printerjob`, `POST /printerjob/{id}/cancel`, `DELETE /printerjob/{id}`, agent job state updates | * | `warehouse` | `{}` | `POST /warehouse`, `PUT /warehouse/{id}`, `PATCH /warehouse/{id}`, `DELETE /warehouse/{id}` | * | `supplier` | `{}` | `POST /supplier`, `PATCH /supplier/{id}`, `DELETE /supplier/{id}` | * | `vfs` | `{}` | VFS uploads and filesystem mutations such as `POST /vfs/upload`, `POST /vfs/mkdir`, `POST /vfs/rename`, `PUT /vfs/{*path}`, `DELETE /vfs/{*path}` | diff --git a/src/api/routes/printerjob.js b/src/api/routes/printerjob.js index 7a7d1bf..816ce1f 100644 --- a/src/api/routes/printerjob.js +++ b/src/api/routes/printerjob.js @@ -1,5 +1,4 @@ import * as printerjobDb from '../../db/printerjob.js'; -import { emit } from '../sse.js'; import { notifyAgentJob } from '../agent/index.js'; // #region Helpers @@ -188,7 +187,6 @@ export function register(app, basePath = '') { * description: Creates a new print job for an agent printer. Notifies the agent in real time. * security: * - cookieAuth: [] - * x-signals: [printerjob] * requestBody: * required: true * content: @@ -249,7 +247,6 @@ export function register(app, basePath = '') { notifyAgentJob(job.printeragentId, 'created', job); } - emit('printerjob', { companyId: selected.companyId, data: { job } }); res.status(201).json({ printerjob: job }); } catch (error) { const status = printerjobErrorStatus(error); @@ -271,7 +268,6 @@ export function register(app, basePath = '') { * Notifies connected agents in real time. * security: * - cookieAuth: [] - * x-signals: [printerjob] * requestBody: * content: * application/json: @@ -318,7 +314,6 @@ export function register(app, basePath = '') { if (job.printeragentId) { notifyAgentJob(job.printeragentId, 'cancelled', job); } - emit('printerjob', { companyId: selected.companyId, data: { job } }); cancelledJobs.push(job); } catch (e) { console.error(`Failed to cancel printerjob #${j.id}:`, e); @@ -348,7 +343,6 @@ export function register(app, basePath = '') { * description: Marks a print job as cancelled and notifies the connected agent in real time. * security: * - cookieAuth: [] - * x-signals: [printerjob] * parameters: * - in: path * name: id @@ -388,7 +382,6 @@ export function register(app, basePath = '') { notifyAgentJob(job.printeragentId, 'cancelled', job); } - emit('printerjob', { companyId: selected.companyId, data: { job } }); res.status(200).json({ success: true, printerjob: job }); } catch (error) { const status = printerjobErrorStatus(error); @@ -410,7 +403,6 @@ export function register(app, basePath = '') { * event to the connected printer agent before deletion. * security: * - cookieAuth: [] - * x-signals: [printerjob] * parameters: * - in: path * name: id @@ -450,10 +442,6 @@ export function register(app, basePath = '') { notifyAgentJob(job.printeragentId, 'cancelled', job); } - emit('printerjob', { - companyId: selected.companyId, - data: { jobId: job.id, state: 'cancelled' }, - }); res.status(200).json({ success: true, deletedJob: job }); } catch (error) { const status = printerjobErrorStatus(error); diff --git a/src/api/routes/zpljob.js b/src/api/routes/zpljob.js index ab4cf16..c099260 100644 --- a/src/api/routes/zpljob.js +++ b/src/api/routes/zpljob.js @@ -1,5 +1,4 @@ import * as printerjobDb from '../../db/printerjob.js'; -import { emit } from '../sse.js'; import { notifyAgentJob } from '../agent/index.js'; // #region Helpers @@ -73,7 +72,6 @@ export function register(app, basePath = '') { * is automatically applied. The connected printer agent receives an immediate real-time event. * security: * - cookieAuth: [] - * x-signals: [printerjob] * requestBody: * required: true * content: @@ -162,7 +160,6 @@ export function register(app, basePath = '') { notifyAgentJob(job.printeragentId, 'created', job); } - emit('printerjob', { companyId: selected.companyId, data: { job } }); res.status(201).json({ printerjob: job }); } catch (error) { const status = printerjobErrorStatus(error);