emilsoftware-utilities 2.0.0-dev.33 → 2.0.0-dev.34

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.
Files changed (30) hide show
  1. package/dist/accessi-module/Console/console.css +10 -0
  2. package/dist/accessi-module/Console/console.js +99 -9
  3. package/dist/accessi-module/Console/console.js.map +1 -1
  4. package/dist/accessi-module/Console/generated/accessiApi.d.ts +2 -2
  5. package/dist/accessi-module/Console/generated/accessiApi.js.map +1 -1
  6. package/dist/accessi-module/Console/index.html +6 -0
  7. package/dist/accessi-module/Console/wiki.js +5 -2
  8. package/dist/accessi-module/Console/wiki.js.map +1 -1
  9. package/dist/accessi-module/Controllers/ConfiguratorController.d.ts +1 -3
  10. package/dist/accessi-module/Controllers/ConfiguratorController.js +4 -17
  11. package/dist/accessi-module/Controllers/ConfiguratorController.js.map +1 -1
  12. package/dist/accessi-module/Controllers/FiltriController.js +4 -4
  13. package/dist/accessi-module/Controllers/FiltriController.js.map +1 -1
  14. package/dist/accessi-module/Controllers/PermissionController.js +14 -14
  15. package/dist/accessi-module/Controllers/PermissionController.js.map +1 -1
  16. package/dist/accessi-module/Controllers/ServiceTokenController.js +1 -1
  17. package/dist/accessi-module/Controllers/ServiceTokenController.js.map +1 -1
  18. package/dist/accessi-module/Controllers/UserController.js +8 -8
  19. package/dist/accessi-module/Controllers/UserController.js.map +1 -1
  20. package/dist/accessi-module/Services/UserService/UserService.d.ts +0 -2
  21. package/dist/accessi-module/Services/UserService/UserService.js +0 -16
  22. package/dist/accessi-module/Services/UserService/UserService.js.map +1 -1
  23. package/dist/accessi-module/federated-auth/FederatedAuthController.js +15 -15
  24. package/dist/accessi-module/federated-auth/FederatedAuthController.js.map +1 -1
  25. package/dist/accessi-module/security/accessControl.d.ts +11 -2
  26. package/dist/accessi-module/security/accessControl.js +28 -4
  27. package/dist/accessi-module/security/accessControl.js.map +1 -1
  28. package/dist/emilsoftware-utilities-2.0.0-dev.34.tgz +0 -0
  29. package/package.json +2 -2
  30. package/dist/emilsoftware-utilities-2.0.0-dev.33.tgz +0 -0
@@ -616,3 +616,13 @@ article h3 { margin-bottom: var(--s2); }
616
616
  @media (prefers-reduced-motion: reduce) {
617
617
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
618
618
  }
619
+
620
+ /* Changelog / markdown body */
621
+ .markdown-body h1 { margin: 0 0 var(--s3); font-size: 1.55rem; color: var(--ink); }
622
+ .markdown-body h2 { margin: var(--s5) 0 var(--s2); padding-top: var(--s3); border-top: 1px solid var(--line); font-size: 1.2rem; color: var(--ink); }
623
+ .markdown-body h3 { margin: var(--s4) 0 var(--s2); font-size: 1rem; color: var(--ink-2); }
624
+ .markdown-body h4 { margin: var(--s3) 0 var(--s1); font-size: .95rem; color: var(--ink-2); }
625
+ .markdown-body strong { color: var(--ink); }
626
+ .markdown-body code { padding: 1px 5px; border-radius: var(--r-sm); color: var(--brand-strong); background: var(--brand-soft); font-family: var(--font-mono); font-size: .92em; }
627
+ .markdown-code { margin: 0; padding: var(--s4); overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
628
+ .markdown-code code { padding: 0; background: transparent; color: var(--ink); white-space: pre; }
@@ -1315,16 +1315,19 @@ POST /api/accessi/auth/confirm-reset-password/{token}
1315
1315
  title: "Console amministrativa",
1316
1316
  summary: "Accesso, sezioni e che cosa si pu\xF2 fare.",
1317
1317
  blocks: [
1318
- p(`La console \xE8 servita dal modulo su /api/accessi/console e richiede un superutente Accessi. Non ha stato proprio: ogni azione chiama le API protette con il JWT dell'utente connesso.`),
1318
+ p(`La console \xE8 servita dal modulo su /api/accessi/console. Non ha stato proprio: ogni azione chiama le API protette con il JWT dell'utente connesso.`),
1319
1319
  list([
1320
1320
  `Utenti: elenco, creazione locale o SSO, profilo, ruoli, grant diretti, stato, 2FA.`,
1321
1321
  `Ruoli e grant: CRUD dei ruoli con l'albero delle abilitazioni.`,
1322
1322
  `Menu e gruppi: CRUD di gruppi, menu e tipi menu.`,
1323
1323
  `Filtri: filtri utente e tipi filtro.`,
1324
1324
  `Token di servizio: creazione, rotazione, revoca.`,
1325
- `SSO: provider e identit\xE0.`
1325
+ `SSO: provider e identit\xE0.`,
1326
+ `Wiki e Changelog: documentazione e novit\xE0 della libreria.`
1326
1327
  ]),
1327
- note("info", `Accesso`, `Apri /api/accessi/console e accedi con un utente con flagSuper=true. Le sezioni sono raggiungibili anche tramite deep link (per esempio /api/accessi/console/menu-e-gruppi/menu).`)
1328
+ note("info", `Superutente (FLGSUPER)`, `Riceve TUTTE le abilitazioni al livello massimo (30) dopo il login. In console vede solo la sezione Utenti e gestisce utenti, ruoli e grant.`),
1329
+ note("info", `Admin (FLGADMIN)`, `Accede a tutta la console (catalogo, token, SSO, utenti) ma NON conferisce abilitazioni: i menu restano quelli assegnati via ABILITAZIONI/RUOLI_MNU.`),
1330
+ note("info", `Accesso`, `Apri /api/accessi/console e accedi con un utente con FLGSUPER o FLGADMIN. Le sezioni sono raggiungibili anche tramite deep link (per esempio /api/accessi/console/menu-e-gruppi/menu).`)
1328
1331
  ]
1329
1332
  },
1330
1333
  // -------------------------------------------------------------------------
@@ -1463,6 +1466,9 @@ function buildAiDigest() {
1463
1466
  return lines.join("\n").replace(/\n{3,}/g, "\n\n").trim();
1464
1467
  }
1465
1468
 
1469
+ // src/accessi-module/Console/changelog.md
1470
+ var changelog_default = "# Changelog Accessi\n\nNovit\xE0 e modifiche rilevanti della libreria `emilsoftware-utilities` (modulo Accessi).\n\n## 2.0.0-dev.33\n\n### Cambiamenti\n- Rimosse le logiche applicative residue dallo schema Accessi:\n - `MENU_GRP.NOMECAMPO`\n - `UTENTI.ENABLEIA`\n - `UTENTI_CONFIG.PAGDEF`\n - `UTENTI.CELLUTE`\n- Telefono canonico: `UTENTI_CONFIG.CELLULARE` (allargato a `VARCHAR(30)`).\n- Migrazione automatica: copia `UTENTI.CELLUTE` \u2192 `UTENTI_CONFIG.CELLULARE`, poi `DROP` delle colonne obsolete.\n- Ruoli chiariti:\n - `FLGSUPER`: superutente, riceve **tutte** le abilitazioni al livello massimo (30) dopo il login; in console vede **solo** la sezione **Utenti**.\n - `FLGADMIN`: accede a **tutta** la console (catalogo, token, SSO, utenti) ma **non** influisce sulle abilitazioni.\n- Aggiunta la sezione **Changelog** in console (sotto la Wiki).\n\n### Note\n- `FILTRI` e `FILTRI_TIPO` restano invariati (piano di migrazione futuro).\n- I backend che usavano i campi rimossi devono gestirli in tabelle proprie.\n\n## 2.0.0-dev.32\n\n### Cambiamenti\n- Rimosso il supporto ai flag applicativi in `UTENTI_CONFIG`: `FLGMOP`, `FLGPIANA`, `FLGADDETTI`, `FLGOSPITI`, `FLGPIANARFID`, `FLGCONTA`, `FLGCUBI`, `FLGCICLPASS`, `FLGDIPENDENTI`, `FLGINVENTARI`, `CAUMOV`, `NUMMAC`, `RAGSOCCLI`.\n- Rinominata la colonna `FLGADMINCONFIG` in `FLGADMIN` (con copia dei valori e `DROP`).\n\n## 2.0.0-dev.31\n\n### Aggiunte\n- Esposizione dei servizi Accessi all'host Express (`getAccessiModuleServices`) per delegare login, SSO e token senza reimplementarli.\n\n### Correzioni\n- `UserService.getUsers`: filtri estesi (`codiceUtente[]`, `numRep[]`, `codDipendente`, `cellulare`, `tipFil`, `flagSuper`).\n\n## 2.0.0-dev.24\n\n### Cambiamenti (breaking)\n- Chiavi JWT derivate per scopo (`access`, `reset`, `2fa`) e claim `typ` obbligatorio: gli access token precedenti non sono pi\xF9 validi.\n- Endpoint Allegati protetti di default.\n- Pool di connessioni attivo di default (`poolSize` 5).\n\n### Aggiunte\n- Service token macchina-a-macchina (gestione, guard, console).\n- CRUD completo dei cataloghi dalla console Accessi.\n- Supporto Firebird 2.5 nel migrator e nei test di integrazione.\n";
1471
+
1466
1472
  // src/accessi-module/Console/help.ts
1467
1473
  var p2 = (text) => ({ kind: "p", text });
1468
1474
  var list2 = (items) => ({ kind: "list", items });
@@ -1833,7 +1839,8 @@ var routeSegment = {
1833
1839
  ssoProviders: "sso/provider",
1834
1840
  ssoUsers: "sso/utenti",
1835
1841
  tokens: "token-di-servizio",
1836
- wiki: "wiki"
1842
+ wiki: "wiki",
1843
+ changelog: "changelog"
1837
1844
  };
1838
1845
  var routeView = Object.fromEntries(Object.entries(routeSegment).map(([view, segment]) => [segment, view]));
1839
1846
  var parentDefaultView = {
@@ -2022,6 +2029,10 @@ function viewFromLocation() {
2022
2029
  return routeView[decoded] ?? parentDefaultView[decoded] ?? "users";
2023
2030
  }
2024
2031
  async function navigate(view, replace = false) {
2032
+ if (!isViewAllowed(view)) {
2033
+ view = "users";
2034
+ replace = true;
2035
+ }
2025
2036
  const destination = routePath(view);
2026
2037
  if (window.location.pathname !== destination) {
2027
2038
  window.history[replace ? "replaceState" : "pushState"]({ view }, "", destination);
@@ -2029,8 +2040,26 @@ async function navigate(view, replace = false) {
2029
2040
  if (view === "users") usersPage = 0;
2030
2041
  await show(view);
2031
2042
  }
2032
- function requireAdmin() {
2033
- if (!currentUser?.flagSuper) throw new Error("La console richiede un superutente Accessi.");
2043
+ function requireConsoleAccess() {
2044
+ if (!currentUser?.flagSuper && !currentUser?.flagAdmin) {
2045
+ throw new Error("La console richiede un superutente o un admin Accessi.");
2046
+ }
2047
+ }
2048
+ function isViewAllowed(view) {
2049
+ if (!currentUser) return false;
2050
+ if (currentUser.flagAdmin) return true;
2051
+ return view === "users";
2052
+ }
2053
+ function applyRoleNavigation() {
2054
+ document.querySelectorAll("#nav [data-view]").forEach((link) => {
2055
+ const view = link.dataset.view;
2056
+ const item = link.closest("li") ?? link;
2057
+ item.hidden = !isViewAllowed(view);
2058
+ });
2059
+ document.querySelectorAll("#nav details[data-nav-group]").forEach((branch) => {
2060
+ const hasVisible = Array.from(branch.querySelectorAll("[data-view]")).some((link) => !link.closest("li").hidden);
2061
+ branch.hidden = !hasVisible;
2062
+ });
2034
2063
  }
2035
2064
  function formValues(form) {
2036
2065
  return Object.fromEntries(new FormData(form).entries());
@@ -2234,9 +2263,11 @@ async function bootstrap() {
2234
2263
  if (!token) throw new Error("Inserisci le credenziali amministrative.");
2235
2264
  const payload = result(await getUserByToken({ token }));
2236
2265
  currentUser = payload.userData;
2237
- requireAdmin();
2266
+ requireConsoleAccess();
2267
+ applyRoleNavigation();
2238
2268
  await detectFederatedAuthentication();
2239
- byId("who").textContent = `${currentUser.email} - superutente`;
2269
+ const roleLabel = currentUser.flagSuper && currentUser.flagAdmin ? "super + admin" : currentUser.flagAdmin ? "admin" : "superutente";
2270
+ byId("who").textContent = `${currentUser.email} - ${roleLabel}`;
2240
2271
  byId("sso-navigation").hidden = !federatedAuthenticationAvailable;
2241
2272
  finishBoot("console");
2242
2273
  await navigate(viewFromLocation(), window.location.pathname === consoleBasePath);
@@ -3000,6 +3031,64 @@ async function showWiki(sectionId) {
3000
3031
  showNotice("Documentazione per AI copiata negli appunti.");
3001
3032
  });
3002
3033
  }
3034
+ function inlineMarkdown(text) {
3035
+ return escapeHtml(text).replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(/`([^`]+)`/g, "<code>$1</code>");
3036
+ }
3037
+ function renderMarkdown(markdown) {
3038
+ const lines = markdown.replace(/\r\n/g, "\n").split("\n");
3039
+ const html = [];
3040
+ let inList = false;
3041
+ let inCode = false;
3042
+ const closeList = () => {
3043
+ if (inList) {
3044
+ html.push("</ul>");
3045
+ inList = false;
3046
+ }
3047
+ };
3048
+ for (const line of lines) {
3049
+ if (line.startsWith("```")) {
3050
+ closeList();
3051
+ html.push(inCode ? "</code></pre>" : '<pre class="markdown-code"><code>');
3052
+ inCode = !inCode;
3053
+ continue;
3054
+ }
3055
+ if (inCode) {
3056
+ html.push(escapeHtml(line));
3057
+ continue;
3058
+ }
3059
+ const heading = /^(#{1,4})\s+(.*)$/.exec(line);
3060
+ if (heading) {
3061
+ closeList();
3062
+ const level = (heading[1] ?? "").length;
3063
+ html.push(`<h${level}>${inlineMarkdown(heading[2] ?? "")}</h${level}>`);
3064
+ continue;
3065
+ }
3066
+ const bullet = /^\s*[-*]\s+(.*)$/.exec(line);
3067
+ if (bullet) {
3068
+ if (!inList) {
3069
+ html.push("<ul>");
3070
+ inList = true;
3071
+ }
3072
+ html.push(`<li>${inlineMarkdown(bullet[1] ?? "")}</li>`);
3073
+ continue;
3074
+ }
3075
+ if (line.trim() === "") {
3076
+ closeList();
3077
+ continue;
3078
+ }
3079
+ closeList();
3080
+ html.push(`<p>${inlineMarkdown(line)}</p>`);
3081
+ }
3082
+ if (inCode) html.push("</code></pre>");
3083
+ closeList();
3084
+ return html.join("");
3085
+ }
3086
+ async function showChangelog() {
3087
+ render(`<div class="wiki"><article class="wiki-content markdown-body">
3088
+ <header class="wiki-section-head"><h2>Changelog</h2><p>Novita e modifiche rilevanti del modulo Accessi.</p></header>
3089
+ ${renderMarkdown(changelog_default)}
3090
+ </article></div>`);
3091
+ }
3003
3092
  async function show(view) {
3004
3093
  try {
3005
3094
  showNotice("");
@@ -3014,7 +3103,8 @@ async function show(view) {
3014
3103
  ssoProviders: showSsoProviders,
3015
3104
  ssoUsers: showSsoUsers,
3016
3105
  tokens: showServiceTokens,
3017
- wiki: showWiki
3106
+ wiki: showWiki,
3107
+ changelog: showChangelog
3018
3108
  };
3019
3109
  setActiveNavigation(view);
3020
3110
  const renderView = views[view];