@esfaenza/flow-builder 20.3.7 → 20.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1259,12 +1259,74 @@ const BUCKET_BY_NAME = new Map([
|
|
|
1259
1259
|
['trace', 'Info'],
|
|
1260
1260
|
['verbose', 'Info'],
|
|
1261
1261
|
]);
|
|
1262
|
-
/**
|
|
1262
|
+
/**
|
|
1263
|
+
* L'enum serializzato come **numero**, nell'ordine di dichiarazione di
|
|
1264
|
+
* `FlowValidationSeverity` lato backend: `Info = 0, Warning = 1, Error = 2` — gravita'
|
|
1265
|
+
* crescente, non decrescente. L'ordine non e' intuibile e sbagliarlo e' silenzioso al
|
|
1266
|
+
* contrario (un errore mostrato come nota), quindi qui vale solo questo elenco.
|
|
1267
|
+
*
|
|
1268
|
+
* Il contratto vuole i **nomi** (§7): la libreria C# registra uno `StringEnumConverter`
|
|
1269
|
+
* proprio per questo. Un host che serializza con impostazioni proprie manda i numeri — questa
|
|
1270
|
+
* mappa e' la rete, non la strada giusta: la cura sta nel converter lato backend.
|
|
1271
|
+
*/
|
|
1272
|
+
const BUCKET_BY_ORDINAL = ['Info', 'Warning', 'Error'];
|
|
1273
|
+
/**
|
|
1274
|
+
* Il valore inatteso si segnala **una volta per forma**, non a ogni rilievo: la validazione
|
|
1275
|
+
* ricalcola in continuazione e un warn per rilievo renderebbe la console illeggibile.
|
|
1276
|
+
*/
|
|
1277
|
+
const REPORTED_UNEXPECTED = new Set();
|
|
1278
|
+
/**
|
|
1279
|
+
* Un livello sconosciuto e' una nota: si mostra, non si nasconde.
|
|
1280
|
+
*
|
|
1281
|
+
* Il parametro e' `unknown` di proposito: `FlowIssueSeverity` promette una stringa, ma il tipo
|
|
1282
|
+
* e' aperto perche' il backend decide i livelli (§13.11) e in un ambiente reale e' arrivato un
|
|
1283
|
+
* valore che **non** era una stringa — `severity.trim is not a function`. Un `TypeError` qui
|
|
1284
|
+
* uccide il `computed` dei conteggi e con esso l'intero pannello dei problemi, quindi la
|
|
1285
|
+
* normalizzazione accetta qualunque forma e non lancia mai.
|
|
1286
|
+
*/
|
|
1263
1287
|
function severityBucket(severity) {
|
|
1264
|
-
|
|
1265
|
-
|
|
1288
|
+
return severityBucketOf(severity) ?? 'Info';
|
|
1289
|
+
}
|
|
1290
|
+
function severityBucketOf(severity, depth = 0) {
|
|
1291
|
+
if (severity === null || severity === undefined) {
|
|
1292
|
+
return null;
|
|
1266
1293
|
}
|
|
1267
|
-
|
|
1294
|
+
if (typeof severity === 'string') {
|
|
1295
|
+
const name = severity?.trim()?.toLowerCase();
|
|
1296
|
+
if (!name) {
|
|
1297
|
+
return null;
|
|
1298
|
+
}
|
|
1299
|
+
// Anche una stringa puo' portare il numero dell'enum ("1"): si prova prima per nome. Un
|
|
1300
|
+
// nome nuovo non si segnala — il backend puo' aggiungerne (§13.11) e cadere in `Info` e'
|
|
1301
|
+
// il comportamento previsto, non un difetto da mostrare in console.
|
|
1302
|
+
return BUCKET_BY_NAME.get(name) ?? bucketByOrdinal(Number(name));
|
|
1303
|
+
}
|
|
1304
|
+
if (typeof severity === 'number' || typeof severity === 'bigint') {
|
|
1305
|
+
return bucketByOrdinal(Number(severity)) ?? unexpected(severity, `number:${severity}`);
|
|
1306
|
+
}
|
|
1307
|
+
// `{ name, value }`, `{ severity }`, `{ level }`: si scende una volta sola sul primo campo
|
|
1308
|
+
// riconoscibile — oltre non e' piu' normalizzazione, e' indovinare.
|
|
1309
|
+
if (typeof severity === 'object' && depth === 0) {
|
|
1310
|
+
const box = severity;
|
|
1311
|
+
for (const key of ['name', 'severity', 'level', 'label', 'code', 'value']) {
|
|
1312
|
+
const bucket = severityBucketOf(box[key], depth + 1);
|
|
1313
|
+
if (bucket) {
|
|
1314
|
+
return bucket;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
return unexpected(severity, `${typeof severity}`);
|
|
1319
|
+
}
|
|
1320
|
+
function bucketByOrdinal(value) {
|
|
1321
|
+
return Number.isInteger(value) ? (BUCKET_BY_ORDINAL[value] ?? null) : null;
|
|
1322
|
+
}
|
|
1323
|
+
/** Nessun secchio riconosciuto: si dice **cosa** e' arrivato, poi si cade su `Info`. */
|
|
1324
|
+
function unexpected(severity, key) {
|
|
1325
|
+
if (!REPORTED_UNEXPECTED.has(key)) {
|
|
1326
|
+
REPORTED_UNEXPECTED.add(key);
|
|
1327
|
+
console.warn('[flow-builder] gravita’ di rilievo non riconosciuta, trattata come nota:', severity);
|
|
1328
|
+
}
|
|
1329
|
+
return null;
|
|
1268
1330
|
}
|
|
1269
1331
|
/** L'ordine in cui si presentano: prima cio' che blocca l'attivazione. */
|
|
1270
1332
|
const SEVERITY_BUCKETS = ['Error', 'Warning', 'Info'];
|