feat(planning): grille hebdomadaire complète avec API et filtres
- Connexion API via proxy Angular (résolution CORS, base path /api) - Import CSS ng-zorro global pour les modales et composants - Filtres Camion/Show câblés sur l'affichage de la grille - Camions affichés via TrucksService (linkés au show du même créneau) - Panneau de détails : spectacles + camions du jour sélectionné - Modale de création de spectacle stylisée avec fond et centrage - Positionnement précis des events à la minute dans leur créneau - Auto-scroll vers l'heure courante au chargement - Ligne "maintenant" sur la colonne du jour actuel - Régénération des services OpenAPI (nouveaux noms de types) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+30
-29
@@ -8,13 +8,12 @@ const node_crypto_1 = require("node:crypto");
|
||||
const types_js_1 = require("../types.js");
|
||||
const raw_body_1 = __importDefault(require("raw-body"));
|
||||
const content_type_1 = __importDefault(require("content-type"));
|
||||
const node_url_1 = require("node:url");
|
||||
const MAXIMUM_MESSAGE_SIZE = '4mb';
|
||||
const url_1 = require("url");
|
||||
const MAXIMUM_MESSAGE_SIZE = "4mb";
|
||||
/**
|
||||
* Server transport for SSE: this will send messages over an SSE connection and receive messages from HTTP POST requests.
|
||||
*
|
||||
* This transport is only available in Node.js environments.
|
||||
* @deprecated SSEServerTransport is deprecated. Use StreamableHTTPServerTransport instead.
|
||||
*/
|
||||
class SSEServerTransport {
|
||||
/**
|
||||
@@ -45,7 +44,7 @@ class SSEServerTransport {
|
||||
// Validate Origin header if allowedOrigins is configured
|
||||
if (this._options.allowedOrigins && this._options.allowedOrigins.length > 0) {
|
||||
const originHeader = req.headers.origin;
|
||||
if (originHeader && !this._options.allowedOrigins.includes(originHeader)) {
|
||||
if (!originHeader || !this._options.allowedOrigins.includes(originHeader)) {
|
||||
return `Invalid Origin header: ${originHeader}`;
|
||||
}
|
||||
}
|
||||
@@ -58,26 +57,27 @@ class SSEServerTransport {
|
||||
*/
|
||||
async start() {
|
||||
if (this._sseResponse) {
|
||||
throw new Error('SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.');
|
||||
throw new Error("SSEServerTransport already started! If using Server class, note that connect() calls start() automatically.");
|
||||
}
|
||||
this.res.writeHead(200, {
|
||||
'Content-Type': 'text/event-stream',
|
||||
'Cache-Control': 'no-cache, no-transform',
|
||||
Connection: 'keep-alive'
|
||||
"Content-Type": "text/event-stream",
|
||||
"Cache-Control": "no-cache, no-transform",
|
||||
Connection: "keep-alive",
|
||||
});
|
||||
// Send the endpoint event
|
||||
// Use a dummy base URL because this._endpoint is relative.
|
||||
// This allows using URL/URLSearchParams for robust parameter handling.
|
||||
const dummyBase = 'http://localhost'; // Any valid base works
|
||||
const endpointUrl = new node_url_1.URL(this._endpoint, dummyBase);
|
||||
const endpointUrl = new url_1.URL(this._endpoint, dummyBase);
|
||||
endpointUrl.searchParams.set('sessionId', this._sessionId);
|
||||
// Reconstruct the relative URL string (pathname + search + hash)
|
||||
const relativeUrlWithSession = endpointUrl.pathname + endpointUrl.search + endpointUrl.hash;
|
||||
this.res.write(`event: endpoint\ndata: ${relativeUrlWithSession}\n\n`);
|
||||
this._sseResponse = this.res;
|
||||
this.res.on('close', () => {
|
||||
this.res.on("close", () => {
|
||||
var _a;
|
||||
this._sseResponse = undefined;
|
||||
this.onclose?.();
|
||||
(_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
|
||||
});
|
||||
}
|
||||
/**
|
||||
@@ -86,8 +86,9 @@ class SSEServerTransport {
|
||||
* This should be called when a POST request is made to send a message to the server.
|
||||
*/
|
||||
async handlePostMessage(req, res, parsedBody) {
|
||||
var _a, _b, _c, _d;
|
||||
if (!this._sseResponse) {
|
||||
const message = 'SSE connection not established';
|
||||
const message = "SSE connection not established";
|
||||
res.writeHead(500).end(message);
|
||||
throw new Error(message);
|
||||
}
|
||||
@@ -95,60 +96,60 @@ class SSEServerTransport {
|
||||
const validationError = this.validateRequestHeaders(req);
|
||||
if (validationError) {
|
||||
res.writeHead(403).end(validationError);
|
||||
this.onerror?.(new Error(validationError));
|
||||
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, new Error(validationError));
|
||||
return;
|
||||
}
|
||||
const authInfo = req.auth;
|
||||
const requestInfo = { headers: req.headers };
|
||||
let body;
|
||||
try {
|
||||
const ct = content_type_1.default.parse(req.headers['content-type'] ?? '');
|
||||
if (ct.type !== 'application/json') {
|
||||
const ct = content_type_1.default.parse((_b = req.headers["content-type"]) !== null && _b !== void 0 ? _b : "");
|
||||
if (ct.type !== "application/json") {
|
||||
throw new Error(`Unsupported content-type: ${ct.type}`);
|
||||
}
|
||||
body =
|
||||
parsedBody ??
|
||||
(await (0, raw_body_1.default)(req, {
|
||||
limit: MAXIMUM_MESSAGE_SIZE,
|
||||
encoding: ct.parameters.charset ?? 'utf-8'
|
||||
}));
|
||||
body = parsedBody !== null && parsedBody !== void 0 ? parsedBody : await (0, raw_body_1.default)(req, {
|
||||
limit: MAXIMUM_MESSAGE_SIZE,
|
||||
encoding: (_c = ct.parameters.charset) !== null && _c !== void 0 ? _c : "utf-8",
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
res.writeHead(400).end(String(error));
|
||||
this.onerror?.(error);
|
||||
(_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await this.handleMessage(typeof body === 'string' ? JSON.parse(body) : body, { requestInfo, authInfo });
|
||||
}
|
||||
catch {
|
||||
catch (_e) {
|
||||
res.writeHead(400).end(`Invalid message: ${body}`);
|
||||
return;
|
||||
}
|
||||
res.writeHead(202).end('Accepted');
|
||||
res.writeHead(202).end("Accepted");
|
||||
}
|
||||
/**
|
||||
* Handle a client message, regardless of how it arrived. This can be used to inform the server of messages that arrive via a means different than HTTP POST.
|
||||
*/
|
||||
async handleMessage(message, extra) {
|
||||
var _a, _b;
|
||||
let parsedMessage;
|
||||
try {
|
||||
parsedMessage = types_js_1.JSONRPCMessageSchema.parse(message);
|
||||
}
|
||||
catch (error) {
|
||||
this.onerror?.(error);
|
||||
(_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
||||
throw error;
|
||||
}
|
||||
this.onmessage?.(parsedMessage, extra);
|
||||
(_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, parsedMessage, extra);
|
||||
}
|
||||
async close() {
|
||||
this._sseResponse?.end();
|
||||
var _a, _b;
|
||||
(_a = this._sseResponse) === null || _a === void 0 ? void 0 : _a.end();
|
||||
this._sseResponse = undefined;
|
||||
this.onclose?.();
|
||||
(_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);
|
||||
}
|
||||
async send(message) {
|
||||
if (!this._sseResponse) {
|
||||
throw new Error('Not connected');
|
||||
throw new Error("Not connected");
|
||||
}
|
||||
this._sseResponse.write(`event: message\ndata: ${JSON.stringify(message)}\n\n`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user