전 저장소 리팩터링과 SSOT 정비
This commit is contained in:
parent
14ecbd4e7d
commit
3dfddcac6f
173 changed files with 19679 additions and 6952 deletions
766
apps/web/src/pages/admin/admin-ai.css
Normal file
766
apps/web/src/pages/admin/admin-ai.css
Normal file
|
|
@ -0,0 +1,766 @@
|
|||
.aic {
|
||||
width: 100%;
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
color: var(--text-body);
|
||||
}
|
||||
|
||||
.aic-head {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.aic-head h1 {
|
||||
margin: 7px 0 0;
|
||||
color: var(--text-strong);
|
||||
font-size: clamp(1.65rem, 2.4vw, 2.2rem);
|
||||
line-height: 1.12;
|
||||
letter-spacing: -0.035em;
|
||||
}
|
||||
|
||||
.aic-head p {
|
||||
max-width: 720px;
|
||||
margin: 8px 0 0;
|
||||
color: var(--text-body);
|
||||
font-size: var(--fs-sm);
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.aic-head__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.aic-head__stamp {
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.aic-head__stamp b {
|
||||
display: block;
|
||||
margin-top: 2px;
|
||||
color: var(--text-body);
|
||||
font-family: var(--font-num);
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.aic-alert {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid color-mix(in srgb, var(--crit-solid) 34%, var(--border-subtle));
|
||||
border-radius: var(--radius);
|
||||
background: var(--crit-tint);
|
||||
color: var(--crit-text);
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.aic-source {
|
||||
display: grid;
|
||||
grid-template-columns: 11px minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 13px 14px;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius);
|
||||
background: var(--glass-surface-inset);
|
||||
box-shadow: var(--glass-inset-shadow);
|
||||
backdrop-filter: var(--glass-blur);
|
||||
}
|
||||
|
||||
.aic-source__dot {
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
border-radius: 50%;
|
||||
background: var(--warn-solid);
|
||||
box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn-solid) 14%, transparent);
|
||||
}
|
||||
|
||||
.aic-source__dot.is-live {
|
||||
background: var(--pos-solid);
|
||||
box-shadow: 0 0 0 4px color-mix(in srgb, var(--pos-solid) 14%, transparent);
|
||||
}
|
||||
|
||||
.aic-source b,
|
||||
.aic-source span {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.aic-source b {
|
||||
color: var(--text-strong);
|
||||
font-size: var(--fs-sm);
|
||||
}
|
||||
|
||||
.aic-source div > span {
|
||||
margin-top: 2px;
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.aic-window,
|
||||
.aic-mode {
|
||||
display: flex;
|
||||
gap: 3px;
|
||||
padding: 3px;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--bg-surface-2);
|
||||
}
|
||||
|
||||
.aic-window button,
|
||||
.aic-mode button {
|
||||
min-height: 34px;
|
||||
padding: 0 11px;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
font: 650 12px/1 var(--font-sans);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.aic-window button:hover,
|
||||
.aic-mode button:hover {
|
||||
color: var(--text-strong);
|
||||
background: var(--neutral-100);
|
||||
}
|
||||
|
||||
.aic-window button.is-active,
|
||||
.aic-mode button.is-active {
|
||||
color: var(--text-on-accent);
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.aic-window button:focus-visible,
|
||||
.aic-mode button:focus-visible {
|
||||
outline: 2px solid var(--focus-ring);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.aic-ledger {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius);
|
||||
background: var(--bg-surface);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
|
||||
.aic-ledger article {
|
||||
min-width: 0;
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.aic-ledger article + article {
|
||||
border-left: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.aic-ledger span,
|
||||
.aic-ledger small {
|
||||
display: block;
|
||||
color: var(--text-muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.aic-ledger span {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.aic-ledger b {
|
||||
display: block;
|
||||
margin: 8px 0 5px;
|
||||
overflow: hidden;
|
||||
color: var(--text-strong);
|
||||
font-family: var(--font-num);
|
||||
font-size: clamp(1.2rem, 2vw, 1.65rem);
|
||||
line-height: 1;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.aic-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.65fr) minmax(320px, 0.85fr);
|
||||
align-items: start;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.aic-column {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.aic-panel {
|
||||
min-width: 0;
|
||||
padding: 17px;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius);
|
||||
background: var(--glass-surface-strong);
|
||||
box-shadow: var(--glass-inset-shadow);
|
||||
backdrop-filter: var(--glass-blur);
|
||||
}
|
||||
|
||||
.aic-panel__head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.aic-eyebrow {
|
||||
display: block;
|
||||
color: var(--accent-deep);
|
||||
font: 750 10px/1.2 var(--font-num);
|
||||
letter-spacing: 0.12em;
|
||||
}
|
||||
|
||||
.aic-panel h2 {
|
||||
margin: 5px 0 0;
|
||||
color: var(--text-strong);
|
||||
font-size: 1rem;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.aic-panel__meta {
|
||||
color: var(--text-muted);
|
||||
font: 600 11px/1.4 var(--font-num);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.aic-status,
|
||||
.aic-runtime {
|
||||
flex: 0 0 auto;
|
||||
padding: 5px 8px;
|
||||
border-radius: 999px;
|
||||
background: var(--neutral-100);
|
||||
color: var(--text-muted);
|
||||
font-size: 11px;
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.aic-status--ok,
|
||||
.aic-runtime--ok {
|
||||
background: var(--pos-tint);
|
||||
color: var(--pos-text);
|
||||
}
|
||||
|
||||
.aic-status--warn,
|
||||
.aic-status--disabled,
|
||||
.aic-runtime--degraded {
|
||||
background: var(--warn-tint);
|
||||
color: var(--warn-text);
|
||||
}
|
||||
|
||||
.aic-status--exceeded,
|
||||
.aic-runtime--down {
|
||||
background: var(--crit-tint);
|
||||
color: var(--crit-text);
|
||||
}
|
||||
|
||||
.aic-budget__split {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 28px;
|
||||
}
|
||||
|
||||
.aic-metricline {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.aic-metricline b {
|
||||
color: var(--text-strong);
|
||||
font-family: var(--font-num);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.aic-track {
|
||||
height: 7px;
|
||||
margin: 10px 0 8px;
|
||||
overflow: hidden;
|
||||
border-radius: 999px;
|
||||
background: var(--neutral-100);
|
||||
}
|
||||
|
||||
.aic-track > span {
|
||||
display: block;
|
||||
height: 100%;
|
||||
border-radius: inherit;
|
||||
background: var(--warn-solid);
|
||||
}
|
||||
|
||||
.aic-track--coverage > span {
|
||||
background: var(--accent-bright);
|
||||
}
|
||||
|
||||
.aic-budget p,
|
||||
.aic-note {
|
||||
margin: 0;
|
||||
color: var(--text-muted);
|
||||
font-size: 11px;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.aic-chart {
|
||||
display: grid;
|
||||
grid-auto-columns: minmax(44px, 1fr);
|
||||
grid-auto-flow: column;
|
||||
align-items: end;
|
||||
gap: 8px;
|
||||
min-height: 205px;
|
||||
overflow-x: auto;
|
||||
padding: 4px 2px 8px;
|
||||
}
|
||||
|
||||
.aic-chart__day {
|
||||
min-width: 44px;
|
||||
display: grid;
|
||||
grid-template-rows: 18px 126px auto auto;
|
||||
gap: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.aic-chart__value,
|
||||
.aic-chart__date,
|
||||
.aic-chart__day small {
|
||||
overflow: hidden;
|
||||
color: var(--text-muted);
|
||||
font: 600 9px/1.2 var(--font-num);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.aic-chart__rail {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
border-bottom: 1px solid var(--border-strong);
|
||||
background-image: linear-gradient(to top, color-mix(in srgb, var(--border-subtle) 60%, transparent) 1px, transparent 1px);
|
||||
background-size: 100% 25%;
|
||||
}
|
||||
|
||||
.aic-chart__bar {
|
||||
width: min(24px, 68%);
|
||||
min-height: 3px;
|
||||
border-radius: 3px 3px 0 0;
|
||||
background: var(--accent-bright);
|
||||
transition: height var(--dur-base) var(--ease-out);
|
||||
}
|
||||
|
||||
.aic-chart__date {
|
||||
color: var(--text-body);
|
||||
}
|
||||
|
||||
.aic-empty {
|
||||
display: grid;
|
||||
min-height: 112px;
|
||||
place-items: center;
|
||||
padding: 18px;
|
||||
border: 1px dashed var(--border-strong);
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-muted);
|
||||
font-size: var(--fs-sm);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.aic-table-wrap {
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.aic-table {
|
||||
width: 100%;
|
||||
min-width: 720px;
|
||||
border-collapse: collapse;
|
||||
font: 600 11px/1.4 var(--font-num);
|
||||
}
|
||||
|
||||
.aic-table th,
|
||||
.aic-table td {
|
||||
padding: 10px 9px;
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.aic-table th {
|
||||
color: var(--text-muted);
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.aic-table th:first-child,
|
||||
.aic-table td:first-child {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.aic-table tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.aic-table td {
|
||||
color: var(--text-body);
|
||||
}
|
||||
|
||||
.aic-table td:first-child b,
|
||||
.aic-table td:first-child span {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.aic-table td:first-child b {
|
||||
max-width: 220px;
|
||||
overflow: hidden;
|
||||
color: var(--text-strong);
|
||||
font-family: var(--font-sans);
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.aic-table td:first-child span {
|
||||
margin-top: 2px;
|
||||
color: var(--text-muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.aic-share {
|
||||
display: inline-block;
|
||||
width: 36px;
|
||||
height: 4px;
|
||||
margin-right: 6px;
|
||||
overflow: hidden;
|
||||
vertical-align: middle;
|
||||
border-radius: 999px;
|
||||
background: var(--neutral-100);
|
||||
}
|
||||
|
||||
.aic-share > span {
|
||||
display: block;
|
||||
height: 100%;
|
||||
background: var(--clay);
|
||||
}
|
||||
|
||||
.aic-engine {
|
||||
border-color: color-mix(in srgb, var(--accent) 34%, var(--border-subtle));
|
||||
}
|
||||
|
||||
.aic-mode {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.aic-mode button {
|
||||
min-width: 0;
|
||||
white-space: normal;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.aic-engine .vg-field + .vg-field {
|
||||
margin-top: 13px;
|
||||
}
|
||||
|
||||
.aic-engine .vg-field__label {
|
||||
color: var(--text-strong);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.aic-engine .vg-field__hint {
|
||||
color: var(--text-muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.aic-engine .vg-input {
|
||||
width: 100%;
|
||||
font-family: var(--font-num);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.aic-config-meta {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0;
|
||||
margin: 16px 0 0;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.aic-config-meta div {
|
||||
min-width: 0;
|
||||
padding: 9px;
|
||||
}
|
||||
|
||||
.aic-config-meta div:nth-child(even) {
|
||||
border-left: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.aic-config-meta div:nth-child(n + 3) {
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.aic-config-meta dt,
|
||||
.aic-config-meta dd {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.aic-config-meta dt {
|
||||
color: var(--text-muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.aic-config-meta dd {
|
||||
margin-top: 3px;
|
||||
overflow: hidden;
|
||||
color: var(--text-body);
|
||||
font: 600 10px/1.4 var(--font-num);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.aic-engine__foot {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.aic-engine__foot > span {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
overflow: hidden;
|
||||
color: var(--text-muted);
|
||||
font-size: 10px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.aic-cache-score {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.aic-cache-score b {
|
||||
color: var(--text-strong);
|
||||
font: 750 2rem/1 var(--font-num);
|
||||
}
|
||||
|
||||
.aic-cache-score span {
|
||||
color: var(--text-muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.aic-mini-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 1px;
|
||||
margin: 0 0 13px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border-subtle);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--border-subtle);
|
||||
}
|
||||
|
||||
.aic-mini-grid div {
|
||||
padding: 9px;
|
||||
background: var(--bg-surface);
|
||||
}
|
||||
|
||||
.aic-mini-grid dt,
|
||||
.aic-mini-grid dd {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.aic-mini-grid dt {
|
||||
color: var(--text-muted);
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
.aic-mini-grid dd {
|
||||
margin-top: 4px;
|
||||
color: var(--text-strong);
|
||||
font: 700 13px/1 var(--font-num);
|
||||
}
|
||||
|
||||
.aic-integrity {
|
||||
display: grid;
|
||||
gap: 9px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.aic-integrity div {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(70px, 0.55fr) minmax(0, 1fr);
|
||||
gap: 2px 10px;
|
||||
padding-bottom: 9px;
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.aic-integrity div:last-child {
|
||||
padding-bottom: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.aic-integrity dt,
|
||||
.aic-integrity dd {
|
||||
margin: 0;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.aic-integrity dt {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.aic-integrity dd {
|
||||
overflow: hidden;
|
||||
color: var(--text-strong);
|
||||
font-weight: 700;
|
||||
text-align: right;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.aic-integrity span {
|
||||
grid-column: 2;
|
||||
color: var(--text-muted);
|
||||
font: 600 9px/1.3 var(--font-num);
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
@media (max-width: 1180px) {
|
||||
.aic-grid {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.aic-column--side {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.aic-engine {
|
||||
grid-row: span 2;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.aic-head {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.aic-head__actions {
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.aic-source {
|
||||
grid-template-columns: 11px minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.aic-window {
|
||||
grid-column: 1 / -1;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
|
||||
.aic-ledger {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.aic-ledger article + article {
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.aic-ledger article:nth-child(even) {
|
||||
border-left: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.aic-ledger article:nth-child(n + 3) {
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 680px) {
|
||||
.aic-head__stamp {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.aic-budget__split,
|
||||
.aic-column--side {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.aic-budget__split {
|
||||
gap: 18px;
|
||||
}
|
||||
|
||||
.aic-engine {
|
||||
grid-row: auto;
|
||||
}
|
||||
|
||||
.aic-ledger {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.aic-ledger article:nth-child(even) {
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.aic-ledger article:nth-child(n + 2) {
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.aic-ledger article {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(100px, 0.75fr) minmax(0, 1fr);
|
||||
align-items: baseline;
|
||||
gap: 4px 10px;
|
||||
}
|
||||
|
||||
.aic-ledger b {
|
||||
margin: 0;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.aic-ledger small {
|
||||
grid-column: 2;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.aic-panel {
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.aic-panel__head {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.aic-engine__foot {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.aic-engine__foot .vg-btn {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.aic-chart__bar {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,19 +8,6 @@
|
|||
gap: 16px;
|
||||
}
|
||||
|
||||
.ad-root::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
inset: -80px 0 auto auto;
|
||||
width: min(560px, 52vw);
|
||||
height: 420px;
|
||||
background: var(--asset-warm-elements) center / cover no-repeat;
|
||||
opacity: 0.045;
|
||||
filter: saturate(0.75);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ad-blank-probe {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
|
|
@ -651,15 +638,13 @@
|
|||
}
|
||||
|
||||
.ad-user-create label,
|
||||
.ad-users-toolbar label,
|
||||
.ad-user__fields label {
|
||||
.ad-users-toolbar label {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.ad-user-create .ad-checkline,
|
||||
.ad-user__fields .ad-checkline {
|
||||
.ad-user-create .ad-checkline {
|
||||
min-height: 36px;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
|
|
@ -667,8 +652,7 @@
|
|||
}
|
||||
|
||||
.ad-user-create span,
|
||||
.ad-users-toolbar label span,
|
||||
.ad-user__fields span {
|
||||
.ad-users-toolbar label span {
|
||||
color: var(--text-muted);
|
||||
font-size: var(--fs-xs);
|
||||
font-weight: 650;
|
||||
|
|
@ -677,8 +661,8 @@
|
|||
.ad-user-create input,
|
||||
.ad-user-create select,
|
||||
.ad-users-toolbar input,
|
||||
.ad-user__fields input,
|
||||
.ad-user__fields select {
|
||||
.ad-user-table input,
|
||||
.ad-user-table select {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
height: 36px;
|
||||
|
|
@ -689,8 +673,7 @@
|
|||
padding: 0 10px;
|
||||
font: var(--fs-sm) / 1.3 var(--font-sans);
|
||||
}
|
||||
.ad-user-create .ad-checkline input,
|
||||
.ad-user__fields .ad-checkline input {
|
||||
.ad-user-create .ad-checkline input {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
flex: none;
|
||||
|
|
@ -700,8 +683,8 @@
|
|||
.ad-user-create input:focus,
|
||||
.ad-user-create select:focus,
|
||||
.ad-users-toolbar input:focus,
|
||||
.ad-user__fields input:focus,
|
||||
.ad-user__fields select:focus {
|
||||
.ad-user-table input:focus,
|
||||
.ad-user-table select:focus {
|
||||
outline: none;
|
||||
border-color: var(--border-focus);
|
||||
box-shadow: 0 0 0 3px var(--focus-ring);
|
||||
|
|
@ -754,16 +737,237 @@
|
|||
|
||||
.ad-users {
|
||||
flex: 1 1 auto;
|
||||
max-height: min(760px, calc(100vh - 116px));
|
||||
overflow: auto;
|
||||
scrollbar-gutter: stable;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
border: 1px solid var(--hair);
|
||||
border-radius: var(--radius);
|
||||
background: var(--bg-surface);
|
||||
box-shadow: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ad-user-table-scroll {
|
||||
max-width: 100%;
|
||||
max-height: min(760px, calc(100dvh - 220px));
|
||||
overflow: auto;
|
||||
scrollbar-gutter: stable both-edges;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
.ad-user-table-scroll:focus-visible {
|
||||
outline: 2px solid var(--border-focus);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.ad-user-table {
|
||||
width: 100%;
|
||||
min-width: 1440px;
|
||||
table-layout: fixed;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
color: var(--text-body);
|
||||
font-size: var(--fs-xs);
|
||||
}
|
||||
|
||||
.ad-user-table th,
|
||||
.ad-user-table td {
|
||||
min-width: 0;
|
||||
padding: 10px 12px;
|
||||
border: 0;
|
||||
border-bottom: 1px solid color-mix(in srgb, var(--glass-inset-border) 72%, transparent);
|
||||
text-align: left;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.ad-user-table th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 3;
|
||||
height: 42px;
|
||||
padding-block: 6px;
|
||||
background: color-mix(in srgb, var(--glass-canvas) 76%, var(--bg-surface));
|
||||
color: var(--text-muted);
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
-webkit-backdrop-filter: var(--glass-blur);
|
||||
backdrop-filter: var(--glass-blur);
|
||||
}
|
||||
|
||||
.ad-user-table tbody tr {
|
||||
background: color-mix(in srgb, var(--bg-surface) 32%, transparent);
|
||||
transition: background var(--dur-fast) var(--ease-out);
|
||||
}
|
||||
|
||||
.ad-user-table tbody tr:hover {
|
||||
background: color-mix(in srgb, var(--accent-tint) 38%, transparent);
|
||||
}
|
||||
|
||||
.ad-user-table tbody tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.ad-user-table th:nth-child(1) { width: 250px; }
|
||||
.ad-user-table th:nth-child(2) { width: 140px; }
|
||||
.ad-user-table th:nth-child(3) { width: 112px; }
|
||||
.ad-user-table th:nth-child(4) { width: 145px; }
|
||||
.ad-user-table th:nth-child(5) { width: 180px; }
|
||||
.ad-user-table th:nth-child(6) { width: 155px; }
|
||||
.ad-user-table th:nth-child(7) { width: 90px; }
|
||||
.ad-user-table th:nth-child(8) { width: 160px; }
|
||||
.ad-user-table th:nth-child(9) { width: 208px; }
|
||||
|
||||
.ad-user-sort {
|
||||
width: 100%;
|
||||
min-height: 30px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ad-user-sort:hover,
|
||||
.ad-user-sort:focus-visible {
|
||||
color: var(--text-strong);
|
||||
}
|
||||
|
||||
.ad-user-sort:focus-visible {
|
||||
outline: 2px solid var(--border-focus);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.ad-user-sort__indicator {
|
||||
color: var(--accent);
|
||||
font-family: var(--font-num);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.ad-user-table input,
|
||||
.ad-user-table select {
|
||||
height: 32px;
|
||||
font-size: 12.5px;
|
||||
padding-inline: 9px;
|
||||
}
|
||||
|
||||
.ad-user-table__identity {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
grid-template-columns: 34px minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.ad-user-table__avatar {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 50%;
|
||||
background: var(--accent-tint);
|
||||
color: var(--accent-deep);
|
||||
font-weight: 750;
|
||||
}
|
||||
|
||||
.ad-user-table__identity > div,
|
||||
.ad-user-table__role,
|
||||
.ad-user-table__status,
|
||||
.ad-user-table__presence {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.ad-user-table__identity > div > span {
|
||||
overflow: hidden;
|
||||
color: var(--text-muted);
|
||||
font-size: 11px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ad-user-table__badges {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.ad-user-table__badges .vg-badge,
|
||||
.ad-user-table__status .vg-badge {
|
||||
width: max-content;
|
||||
padding: 1px 7px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.ad-user-table__check {
|
||||
min-height: 32px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
color: var(--text-body);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ad-user-table__check input {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
flex: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.ad-user-table__number {
|
||||
display: block;
|
||||
color: var(--text-strong);
|
||||
font-family: var(--font-num);
|
||||
font-size: var(--fs-sm);
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.ad-user-table__presence span {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
color: var(--text-muted);
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.ad-user-table__presence span::before {
|
||||
content: "";
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--neutral-400);
|
||||
}
|
||||
|
||||
.ad-user-table__presence span.is-online {
|
||||
color: var(--pos-text);
|
||||
}
|
||||
|
||||
.ad-user-table__presence span.is-online::before {
|
||||
background: var(--pos-solid);
|
||||
}
|
||||
|
||||
.ad-user-table__presence time {
|
||||
color: var(--text-muted);
|
||||
font-family: var(--font-num);
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ad-user-table-loading {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.ad-user-table-loading > div {
|
||||
min-height: 58px;
|
||||
display: grid;
|
||||
grid-template-columns: 220px 1fr 120px 160px;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid var(--glass-inset-border);
|
||||
}
|
||||
|
||||
.ad-approval-head {
|
||||
|
|
@ -871,25 +1075,6 @@
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.ad-user {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(190px, 0.75fr) minmax(420px, 1.4fr) minmax(138px, 0.42fr) max-content;
|
||||
align-items: center;
|
||||
gap: 10px 12px;
|
||||
padding: 9px 12px;
|
||||
border-top: 1px solid var(--paper-2);
|
||||
background: color-mix(in srgb, var(--bg-surface) 88%, var(--bg-surface-2));
|
||||
}
|
||||
.ad-user:hover {
|
||||
background: var(--bg-surface-2);
|
||||
}
|
||||
|
||||
.ad-user:first-child {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.ad-user__top,
|
||||
.ad-user__id,
|
||||
.ad-user__actions {
|
||||
min-width: 0;
|
||||
|
|
@ -897,12 +1082,6 @@
|
|||
align-items: center;
|
||||
}
|
||||
|
||||
.ad-user__top {
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ad-user__id {
|
||||
gap: 10px;
|
||||
}
|
||||
|
|
@ -934,47 +1113,6 @@
|
|||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.ad-user__badges {
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.ad-user__fields {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(130px, 1.1fr) 96px 104px 112px minmax(118px, 0.95fr) minmax(110px, 0.85fr);
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.ad-user__fields span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ad-user__fields input,
|
||||
.ad-user__fields select {
|
||||
height: 32px;
|
||||
font-size: 12.5px;
|
||||
padding-inline: 9px;
|
||||
}
|
||||
|
||||
.ad-user__meta {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
color: var(--text-muted);
|
||||
font-family: var(--font-num);
|
||||
font-size: var(--fs-xs);
|
||||
}
|
||||
|
||||
.ad-user__meta span {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.ad-user__actions {
|
||||
flex-wrap: nowrap;
|
||||
gap: 8px;
|
||||
|
|
@ -1336,24 +1474,6 @@
|
|||
grid-template-columns: minmax(180px, 1fr) minmax(132px, 0.6fr) minmax(132px, 0.6fr);
|
||||
}
|
||||
|
||||
.ad-user {
|
||||
grid-template-columns: minmax(190px, 0.8fr) minmax(0, 1.2fr) max-content;
|
||||
}
|
||||
|
||||
.ad-user__fields {
|
||||
grid-template-columns: minmax(0, 1fr) 104px;
|
||||
}
|
||||
|
||||
.ad-user__fields span {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.ad-user__meta {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px 14px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
|
|
@ -1376,20 +1496,11 @@
|
|||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.ad-user {
|
||||
grid-template-columns: 1fr;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.ad-approval {
|
||||
grid-template-columns: 1fr;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.ad-user__actions {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.ad-approval__actions {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
|
@ -1413,10 +1524,6 @@
|
|||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.ad-root::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.ad-head {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
|
|
@ -1517,8 +1624,11 @@
|
|||
}
|
||||
|
||||
.ad-users {
|
||||
max-height: none;
|
||||
overflow: visible;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ad-user-table-scroll {
|
||||
max-height: min(68dvh, 680px);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1531,21 +1641,6 @@
|
|||
grid-column: 2;
|
||||
}
|
||||
|
||||
.ad-user__top {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.ad-user__fields {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.ad-user__actions {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ad-approval-metrics {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
|
@ -1555,11 +1650,6 @@
|
|||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.ad-user__actions .vg-btn {
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.ad-approval__actions .vg-btn {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
|
|||
428
apps/web/src/pages/admin/dataNormalization.ts
Normal file
428
apps/web/src/pages/admin/dataNormalization.ts
Normal file
|
|
@ -0,0 +1,428 @@
|
|||
import type {
|
||||
AdminManagedUser,
|
||||
AdminSupportTicket,
|
||||
AdminTicketsResponse,
|
||||
AdminUsersResponse,
|
||||
} from "../../lib/api";
|
||||
|
||||
export interface AdminDataWarning {
|
||||
key: string;
|
||||
message: string;
|
||||
detail: string;
|
||||
}
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> {
|
||||
return value !== null && typeof value === "object"
|
||||
? (value as Record<string, unknown>)
|
||||
: {};
|
||||
}
|
||||
|
||||
function warn(
|
||||
warnings: AdminDataWarning[],
|
||||
key: string,
|
||||
message: string,
|
||||
detail: string,
|
||||
): void {
|
||||
warnings.push({ key, message, detail });
|
||||
}
|
||||
|
||||
function stringField(
|
||||
source: Record<string, unknown>,
|
||||
field: string,
|
||||
fallback: string,
|
||||
warnings: AdminDataWarning[],
|
||||
label: string,
|
||||
): string {
|
||||
const value = source[field];
|
||||
if (typeof value === "string") return value;
|
||||
if (value == null) {
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.${field}`,
|
||||
`${label} 응답에서 ${field} 값이 비어 있어 기본값으로 표시합니다.`,
|
||||
`${field}=null`,
|
||||
);
|
||||
return fallback;
|
||||
}
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.${field}`,
|
||||
`${label} 응답에서 ${field} 타입이 잘못되어 문자열로 변환했습니다.`,
|
||||
`${field}=${typeof value}`,
|
||||
);
|
||||
return String(value);
|
||||
}
|
||||
|
||||
function booleanField(
|
||||
source: Record<string, unknown>,
|
||||
field: string,
|
||||
fallback: boolean,
|
||||
warnings: AdminDataWarning[],
|
||||
label: string,
|
||||
): boolean {
|
||||
const value = source[field];
|
||||
if (typeof value === "boolean") return value;
|
||||
if (value == null) {
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.${field}`,
|
||||
`${label} 응답에서 ${field} 값이 비어 있어 ${fallback ? "true" : "false"}로 표시합니다.`,
|
||||
`${field}=null`,
|
||||
);
|
||||
return fallback;
|
||||
}
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.${field}`,
|
||||
`${label} 응답에서 ${field} 타입이 잘못되어 bool 기본값으로 표시합니다.`,
|
||||
`${field}=${typeof value}`,
|
||||
);
|
||||
return fallback;
|
||||
}
|
||||
|
||||
function numberField(
|
||||
source: Record<string, unknown>,
|
||||
field: string,
|
||||
fallback: number,
|
||||
warnings: AdminDataWarning[],
|
||||
label: string,
|
||||
): number {
|
||||
const value = source[field];
|
||||
if (typeof value === "number" && Number.isFinite(value)) return value;
|
||||
if (typeof value === "string" && value.trim() !== "") {
|
||||
const parsed = Number(value);
|
||||
if (Number.isFinite(parsed)) {
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.${field}`,
|
||||
`${label} 응답에서 ${field}가 문자열이라 숫자로 변환했습니다.`,
|
||||
`${field}=string`,
|
||||
);
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.${field}`,
|
||||
`${label} 응답에서 ${field} 숫자 값이 없어 ${fallback}으로 표시합니다.`,
|
||||
`${field}=${value == null ? "null" : typeof value}`,
|
||||
);
|
||||
return fallback;
|
||||
}
|
||||
|
||||
function cohortIdsField(
|
||||
source: Record<string, unknown>,
|
||||
warnings: AdminDataWarning[],
|
||||
label: string,
|
||||
): string[] {
|
||||
const value = source.cohort_ids;
|
||||
if (!Array.isArray(value)) {
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.cohort_ids`,
|
||||
`${label} 응답에서 cohort_ids가 배열이 아니라 빈 코호트로 표시합니다.`,
|
||||
`cohort_ids=${value == null ? "null" : typeof value}`,
|
||||
);
|
||||
return [];
|
||||
}
|
||||
const normalized = value.filter(
|
||||
(item): item is string => typeof item === "string",
|
||||
);
|
||||
if (normalized.length !== value.length) {
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.cohort_ids.items`,
|
||||
`${label} 응답에서 cohort_ids 내부에 문자열이 아닌 값이 있어 제외했습니다.`,
|
||||
`kept=${normalized.length}, raw=${value.length}`,
|
||||
);
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function numberRecordField(
|
||||
source: Record<string, unknown>,
|
||||
field: string,
|
||||
warnings: AdminDataWarning[],
|
||||
label: string,
|
||||
): Record<string, number> {
|
||||
const value = source[field];
|
||||
if (value == null) {
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.${field}`,
|
||||
`${label} 응답에서 ${field} 값이 비어 있어 빈 집계로 표시합니다.`,
|
||||
`${field}=null`,
|
||||
);
|
||||
return {};
|
||||
}
|
||||
if (typeof value !== "object" || Array.isArray(value)) {
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.${field}`,
|
||||
`${label} 응답에서 ${field} 타입이 잘못되어 빈 집계로 표시합니다.`,
|
||||
`${field}=${typeof value}`,
|
||||
);
|
||||
return {};
|
||||
}
|
||||
const normalized: Record<string, number> = {};
|
||||
for (const [key, raw] of Object.entries(value as Record<string, unknown>)) {
|
||||
if (typeof raw === "number" && Number.isFinite(raw)) {
|
||||
normalized[key] = raw;
|
||||
continue;
|
||||
}
|
||||
const parsed = typeof raw === "string" ? Number(raw) : Number.NaN;
|
||||
if (Number.isFinite(parsed)) {
|
||||
normalized[key] = parsed;
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.${field}.${key}`,
|
||||
`${label} 응답에서 ${field}.${key}가 문자열이라 숫자로 변환했습니다.`,
|
||||
`${field}.${key}=string`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.${field}.${key}`,
|
||||
`${label} 응답에서 ${field}.${key} 숫자 값이 없어 제외했습니다.`,
|
||||
`${field}.${key}=${raw == null ? "null" : typeof raw}`,
|
||||
);
|
||||
}
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function roleField(
|
||||
source: Record<string, unknown>,
|
||||
warnings: AdminDataWarning[],
|
||||
label: string,
|
||||
): AdminManagedUser["role"] {
|
||||
const value = source.role;
|
||||
if (value === "learner" || value === "teacher" || value === "admin") {
|
||||
return value;
|
||||
}
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.role`,
|
||||
`${label} 응답에서 role 값이 계약과 달라 학습자로 표시합니다.`,
|
||||
`role=${String(value)}`,
|
||||
);
|
||||
return "learner";
|
||||
}
|
||||
|
||||
function accountStatusField(
|
||||
source: Record<string, unknown>,
|
||||
warnings: AdminDataWarning[],
|
||||
label: string,
|
||||
): AdminManagedUser["account_status"] {
|
||||
const value = source.account_status;
|
||||
if (value === "pending" || value === "approved" || value === "suspended") {
|
||||
return value;
|
||||
}
|
||||
warn(
|
||||
warnings,
|
||||
`${label}.account_status`,
|
||||
`${label} 응답에서 account_status 값이 계약과 달라 승인 대기로 표시합니다.`,
|
||||
`account_status=${String(value)}`,
|
||||
);
|
||||
return "pending";
|
||||
}
|
||||
|
||||
function userSourceField(
|
||||
source: Record<string, unknown>,
|
||||
parentSource: AdminUsersResponse["source"],
|
||||
): AdminManagedUser["source"] {
|
||||
const value = source.source;
|
||||
return value === "server_session_registry" || value === "database"
|
||||
? value
|
||||
: parentSource;
|
||||
}
|
||||
|
||||
export function normalizeAdminUsersResponse(rawResponse: AdminUsersResponse): {
|
||||
response: AdminUsersResponse;
|
||||
warnings: AdminDataWarning[];
|
||||
} {
|
||||
const warnings: AdminDataWarning[] = [];
|
||||
const root = asRecord(rawResponse);
|
||||
const source: AdminUsersResponse["source"] =
|
||||
root.source === "server_session_registry"
|
||||
? "server_session_registry"
|
||||
: "database";
|
||||
const durable =
|
||||
typeof root.durable === "boolean" ? root.durable : source === "database";
|
||||
const rawUsers = Array.isArray(root.users) ? root.users : [];
|
||||
|
||||
if (!Array.isArray(root.users)) {
|
||||
warn(
|
||||
warnings,
|
||||
"admin.users",
|
||||
"/admin/users 응답에서 users 배열이 없어 빈 목록으로 표시합니다.",
|
||||
`users=${root.users == null ? "null" : typeof root.users}`,
|
||||
);
|
||||
}
|
||||
|
||||
const users = rawUsers.map((item, index): AdminManagedUser => {
|
||||
const sourceRecord = asRecord(item);
|
||||
const label = `users[${index}]`;
|
||||
const userId = stringField(
|
||||
sourceRecord,
|
||||
"user_id",
|
||||
`unknown-${index + 1}`,
|
||||
warnings,
|
||||
label,
|
||||
);
|
||||
return {
|
||||
user_id: userId,
|
||||
email: stringField(sourceRecord, "email", userId, warnings, label),
|
||||
display_name: stringField(
|
||||
sourceRecord,
|
||||
"display_name",
|
||||
userId,
|
||||
warnings,
|
||||
label,
|
||||
),
|
||||
role: roleField(sourceRecord, warnings, label),
|
||||
admin_access: booleanField(
|
||||
sourceRecord,
|
||||
"admin_access",
|
||||
false,
|
||||
warnings,
|
||||
label,
|
||||
),
|
||||
super_admin: booleanField(
|
||||
sourceRecord,
|
||||
"super_admin",
|
||||
false,
|
||||
warnings,
|
||||
label,
|
||||
),
|
||||
account_status: accountStatusField(sourceRecord, warnings, label),
|
||||
cohort_ids: cohortIdsField(sourceRecord, warnings, label),
|
||||
affiliation: stringField(
|
||||
sourceRecord,
|
||||
"affiliation",
|
||||
"",
|
||||
warnings,
|
||||
label,
|
||||
),
|
||||
active_sessions: numberField(
|
||||
sourceRecord,
|
||||
"active_sessions",
|
||||
0,
|
||||
warnings,
|
||||
label,
|
||||
),
|
||||
created_at: numberField(sourceRecord, "created_at", 0, warnings, label),
|
||||
last_seen_at: numberField(
|
||||
sourceRecord,
|
||||
"last_seen_at",
|
||||
0,
|
||||
warnings,
|
||||
label,
|
||||
),
|
||||
source: userSourceField(sourceRecord, source),
|
||||
};
|
||||
});
|
||||
|
||||
return { response: { source, durable, users }, warnings };
|
||||
}
|
||||
|
||||
export function normalizeAdminTicketsResponse(
|
||||
rawResponse: AdminTicketsResponse,
|
||||
): {
|
||||
response: AdminTicketsResponse;
|
||||
warnings: AdminDataWarning[];
|
||||
} {
|
||||
const warnings: AdminDataWarning[] = [];
|
||||
const root = asRecord(rawResponse);
|
||||
const source: AdminTicketsResponse["source"] =
|
||||
root.source === "database" ? "database" : "unavailable";
|
||||
const durable =
|
||||
typeof root.durable === "boolean" ? root.durable : source === "database";
|
||||
const rawTickets = Array.isArray(root.tickets) ? root.tickets : [];
|
||||
if (!Array.isArray(root.tickets)) {
|
||||
warn(
|
||||
warnings,
|
||||
"admin.tickets",
|
||||
"/admin/tickets 응답에서 tickets 배열이 없어 빈 목록으로 표시합니다.",
|
||||
`tickets=${root.tickets == null ? "null" : typeof root.tickets}`,
|
||||
);
|
||||
}
|
||||
|
||||
const summaryRoot = asRecord(root.summary);
|
||||
if (
|
||||
!root.summary ||
|
||||
typeof root.summary !== "object" ||
|
||||
Array.isArray(root.summary)
|
||||
) {
|
||||
warn(
|
||||
warnings,
|
||||
"admin.tickets.summary",
|
||||
"/admin/tickets 응답에서 summary 객체가 없어 기본 집계로 표시합니다.",
|
||||
`summary=${root.summary == null ? "null" : typeof root.summary}`,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
response: {
|
||||
source,
|
||||
durable,
|
||||
generated_at: numberField(
|
||||
root,
|
||||
"generated_at",
|
||||
0,
|
||||
warnings,
|
||||
"admin.tickets",
|
||||
),
|
||||
tickets: rawTickets as AdminSupportTicket[],
|
||||
summary: {
|
||||
total: numberField(
|
||||
summaryRoot,
|
||||
"total",
|
||||
rawTickets.length,
|
||||
warnings,
|
||||
"admin.tickets.summary",
|
||||
),
|
||||
open_count: numberField(
|
||||
summaryRoot,
|
||||
"open_count",
|
||||
0,
|
||||
warnings,
|
||||
"admin.tickets.summary",
|
||||
),
|
||||
high_priority_count: numberField(
|
||||
summaryRoot,
|
||||
"high_priority_count",
|
||||
0,
|
||||
warnings,
|
||||
"admin.tickets.summary",
|
||||
),
|
||||
stale_count: numberField(
|
||||
summaryRoot,
|
||||
"stale_count",
|
||||
0,
|
||||
warnings,
|
||||
"admin.tickets.summary",
|
||||
),
|
||||
by_category: numberRecordField(
|
||||
summaryRoot,
|
||||
"by_category",
|
||||
warnings,
|
||||
"admin.tickets.summary",
|
||||
),
|
||||
by_priority: numberRecordField(
|
||||
summaryRoot,
|
||||
"by_priority",
|
||||
warnings,
|
||||
"admin.tickets.summary",
|
||||
),
|
||||
by_status: numberRecordField(
|
||||
summaryRoot,
|
||||
"by_status",
|
||||
warnings,
|
||||
"admin.tickets.summary",
|
||||
),
|
||||
},
|
||||
},
|
||||
warnings,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue