This commit is contained in:
seb
2026-10-16 15:22:13 +02:00
parent bed19f8b10
commit 5ed634990e
9 changed files with 118 additions and 300 deletions

View File

@@ -15,7 +15,6 @@ import {
parseDraftPath,
requestDraftRead,
requestDraftList,
handleDraftResponse,
notifyDraftUpdate,
} from '../../services/draftManager.js';
@@ -1319,8 +1318,7 @@ export function register(app, basePath = '') {
res.setHeader('Content-Disposition', `inline; filename="${fallbackName}"`);
return res.status(200).send(buffer);
} catch (err) {
const status = err.message?.includes('timed out') ? 504 : 404;
return res.status(status).json({ error: err.message });
return res.status(404).json({ error: err.message });
}
}
@@ -1399,78 +1397,7 @@ export function register(app, basePath = '') {
// #endregion
/**
* @openapi
* /vfs/drafts/response:
* post:
* tags: [Vfs]
* summary: Respond to a frontend draft request
* description: |
* Used by the frontend to answer a server-initiated `draft:request` SSE event
* when reading or listing virtual drafts (`drafts/quote`, `drafts/order`, `drafts/delivery`).
* security:
* - cookieAuth: []
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required: [requestId]
* properties:
* requestId:
* type: string
* description: Unique request ID from the draft:request SSE event
* content:
* description: File content when action was read
* error:
* type: string
* description: Error message if draft retrieval failed on frontend
* files:
* type: array
* description: File listing when action was list
* responses:
* 200:
* description: Response received and resolved
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* 400:
* description: Missing requestId or no company selected
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 404:
* description: Request ID not found or already timed out
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
*/
// #region POST /vfs/drafts/response
app.post(`${basePath}/vfs/drafts/response`, async (req, res) => {
const selected = requireSelectedCompany(req);
if (selected.error) {
return res.status(400).json({ error: selected.error });
}
const { requestId, content, error, files } = req.body || {};
if (!requestId) {
return res.status(400).json({ error: 'requestId is required' });
}
const result = handleDraftResponse({ requestId, content, error, files });
if (!result.handled) {
return res.status(404).json({ error: result.error || 'Request expired or not found' });
}
return res.json({ success: true });
});
// #endregion
/**
* @openapi