identityscope 0.28.3 → 0.28.4

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 (91) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +917 -917
  3. package/SECURITY.md +56 -56
  4. package/dist/node/cli.js +26 -26
  5. package/dist/node/monthly.js +17 -17
  6. package/package.json +2 -2
  7. package/reports/access-profile-members.yaml +29 -29
  8. package/reports/access-profile-membership-counts.yaml +17 -17
  9. package/reports/access-profiles-without-owner.yaml +16 -16
  10. package/reports/access-request-audit-trail.yaml +36 -36
  11. package/reports/accounts-by-source.yaml +19 -19
  12. package/reports/active-identities-without-manager.yaml +22 -22
  13. package/reports/aggregation-failures.yaml +29 -29
  14. package/reports/aggregation-history.yaml +27 -27
  15. package/reports/all-sources.yaml +16 -16
  16. package/reports/application-accounts.yaml +32 -32
  17. package/reports/application-entitlements.yaml +31 -31
  18. package/reports/campaign-progress.yaml +23 -23
  19. package/reports/certification-decisions.yaml +31 -31
  20. package/reports/direct-reports-per-manager.yaml +20 -20
  21. package/reports/disabled-accounts-of-active-people.yaml +33 -33
  22. package/reports/duplicate-emails.yaml +16 -16
  23. package/reports/entitlement-holders.yaml +35 -35
  24. package/reports/entitlements-held-by-inactive-identities.yaml +31 -31
  25. package/reports/entitlements-without-owner.yaml +28 -28
  26. package/reports/identities-by-lifecycle-state.yaml +15 -15
  27. package/reports/identities-missing-key-attributes.yaml +27 -27
  28. package/reports/identities-with-processing-errors.yaml +19 -19
  29. package/reports/identity-attribute-mappings.yaml +27 -27
  30. package/reports/machine-accounts.yaml +28 -28
  31. package/reports/managers-and-direct-reports.yaml +23 -23
  32. package/reports/most-access.yaml +18 -18
  33. package/reports/new-identities.yaml +24 -24
  34. package/reports/old-passwords.yaml +35 -35
  35. package/reports/pending-reviews-by-reviewer.yaml +20 -20
  36. package/reports/person-access.yaml +31 -31
  37. package/reports/privileged-access.yaml +29 -29
  38. package/reports/provisioning-error-causes.yaml +27 -27
  39. package/reports/provisioning-errors.yaml +32 -32
  40. package/reports/provisioning-failures.yaml +28 -28
  41. package/reports/recent-access-requests.yaml +22 -22
  42. package/reports/recent-activity.yaml +32 -32
  43. package/reports/recent-leavers.yaml +34 -34
  44. package/reports/role-members.yaml +29 -29
  45. package/reports/role-membership-counts.yaml +18 -18
  46. package/reports/roles-without-owner.yaml +17 -17
  47. package/reports/sources-needing-attention.yaml +23 -23
  48. package/reports/stuck-access-requests.yaml +29 -29
  49. package/reports/team-access.yaml +30 -30
  50. package/reports/terminated-users-with-active-accounts.yaml +46 -46
  51. package/reports/uncorrelated-accounts.yaml +38 -38
  52. package/ui/js/00-setup.js +6 -6
  53. package/ui/js/01-small-helpers.js +143 -143
  54. package/ui/js/02-connection.js +150 -150
  55. package/ui/js/03-health-check.js +17 -17
  56. package/ui/js/04-library.js +135 -135
  57. package/ui/js/05-pickers.js +163 -163
  58. package/ui/js/06-report-view.js +157 -157
  59. package/ui/js/07-fields.js +85 -85
  60. package/ui/js/08-designer.js +360 -360
  61. package/ui/js/09-yaml.js +22 -22
  62. package/ui/js/10-instant-check.js +171 -171
  63. package/ui/js/11-lookup.js +161 -161
  64. package/ui/js/12-tenant.js +115 -115
  65. package/ui/js/13-source-configuration-and-diagnostics.js +64 -64
  66. package/ui/js/14-certifications.js +68 -68
  67. package/ui/js/15-monthly-report.js +24 -24
  68. package/ui/js/16-ownership.js +39 -39
  69. package/ui/js/17-compare-tenants.js +102 -102
  70. package/ui/js/18-audit.js +181 -181
  71. package/ui/js/19-insights.js +108 -108
  72. package/ui/js/20-role-mining.js +35 -35
  73. package/ui/js/21-share-reports.js +45 -45
  74. package/ui/js/22-partner-overview-all-customer-tenants.js +228 -228
  75. package/ui/js/23-in-app-guidance.js +217 -217
  76. package/ui/js/24-role-tools.js +220 -220
  77. package/ui/js/25-schedules.js +264 -264
  78. package/ui/js/26-start.js +7 -7
  79. package/ui/js/27-warnings.js +224 -224
  80. package/ui/js/28-audit-readiness.js +99 -99
  81. package/ui/js/29-lifecycle.js +182 -182
  82. package/ui/js/30-labs.js +265 -265
  83. package/ui/js/31-build.js +203 -203
  84. package/ui/js/32-lab-examples.js +148 -148
  85. package/ui/js/33-finder.js +89 -89
  86. package/ui/js/34-governance.js +129 -129
  87. package/ui/js/35-watch.js +266 -266
  88. package/ui/js/36-model.js +247 -247
  89. package/ui/js/37-logs-and-watch.js +224 -224
  90. package/ui/shell.html +112 -112
  91. package/ui/style.css +350 -350
package/ui/js/31-build.js CHANGED
@@ -1,203 +1,203 @@
1
- // ---------- Build & test: try changes before making them in ISC (read-only) ----------
2
- state.bt = { tab: 'tlab', impact: {}, pick: '', policy: { usageType: 'CREATE', person: '' }, health: { days: 30 }, drift: {} };
3
- // Build & test holds the tools for trying a change before making it. Where transforms and credentials
4
- // are used and workflow health live on the Tenant page, drift on Audit > Change history, and the role
5
- // change preview on Role tools: one home each.
6
- var BUILD_TABS = [
7
- ['tlab', 'Transform lab', 'sliders'], ['policy', 'Account create preview', 'plus'], ['wlab', 'Workflow lab', 'play'],
8
- ];
9
- /** Redraws whichever page the shared tools are on. */
10
- function rerenderHost() {
11
- if (state.page === 'tenant') renderTenant();
12
- else if (state.page === 'certs') renderAudit();
13
- else renderBuild();
14
- }
15
- function renderBuild() {
16
- var B = state.bt;
17
- var outer = $('build');
18
- outer.textContent = '';
19
- var w = el('div', { className: 'wrap', style: 'max-width:1240px' });
20
- outer.appendChild(w);
21
- w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#6d28d9;background:#ede9fe' }, icon('code')),
22
- el('div', {}, el('h2', { text: 'Build & test' }), el('p', { className: 'desc', text: 'Try changes before you make them in ISC. Everything here runs on this computer or only reads ISC: nothing is created, changed or started.' }))));
23
- var tabs = el('div', { className: 'tabs' });
24
- BUILD_TABS.forEach(function (t) {
25
- tabs.appendChild(el('button', { className: 'tab' + (B.tab === t[0] ? ' active' : ''), onclick: function () { B.tab = t[0]; renderBuild(); } }, icon(t[2]), t[1]));
26
- });
27
- w.appendChild(tabs);
28
- if (!BUILD_TABS.some(function (t) { return t[0] === B.tab; })) B.tab = 'tlab';
29
- if (B.tab === 'policy') renderPolicyPreview(w);
30
- else if (B.tab === 'wlab') renderWorkflowLab(w);
31
- else renderTransformLab(w);
32
- w.appendChild(el('p', { className: 'muted small', style: 'margin-top:18px', text: 'Also: where each transform is used (Tenant > Transforms), workflow runs and failures (Tenant > Workflows), where credentials are used (Tenant > Credential map), drift from an approved baseline (Audit > Change history), and who a role change would affect (Role tools > Preview a role change).' }));
33
- }
34
-
35
- // Transform impact
36
- function renderImpactMap(w) {
37
- var B = state.bt, H = B.impact;
38
- w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' },
39
- el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: 'Before you change a transform: every identity profile, other transform and provisioning policy that uses it, also through other transforms, and how many people that covers. Also lists transforms nothing uses.' }),
40
- el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/build/impact/run', {}, rerenderHost); } }, icon('search'), H.data ? 'Read again' : 'Find where transforms are used')));
41
- if (H.busy) { w.appendChild(busyBox(H.busy)); return; }
42
- if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }
43
- if (!H.data) return;
44
- var d = H.data;
45
- (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
46
- w.appendChild(el('div', { className: 'bigstats' }, stat(d.transforms.length, 'transforms'), stat(d.unused.length, 'used by nothing', d.unused.length ? 'lose' : undefined), stat(d.profiles.length, 'identity profiles'), stat(d.policiesRead, 'provisioning policies read')));
47
- var pick = el('select', { className: 'input', style: 'max-width:420px', 'aria-label': 'Transform' }, el('option', { value: '', text: 'Pick a transform to see where it is used...' }));
48
- d.transforms.forEach(function (t) { pick.appendChild(el('option', { value: t.name, text: t.name + ' (' + t.uses.length + ' use' + (t.uses.length === 1 ? '' : 's') + ')' })); });
49
- pick.value = B.pick;
50
- pick.addEventListener('change', function () { B.pick = pick.value; rerenderHost(); });
51
- w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:12px' }, pick));
52
- var t = d.transforms.filter(function (x) { return x.name === B.pick; })[0];
53
- if (t) {
54
- var people = t.people === null ? 'an unknown number of' : fmtNum(t.people);
55
- w.appendChild(el('div', { className: 'banner ' + (t.uses.length ? 'bad' : 'ok') }, el('b', { text: t.uses.length ? 'Changing "' + t.name + '" affects ' + t.uses.length + ' place' + (t.uses.length === 1 ? '' : 's') : '"' + t.name + '" is not used anywhere IdentityScope can see' }),
56
- t.uses.length ? el('span', { text: t.people ? ' · identity attributes of ' + people + ' people' : '' }) : null));
57
- if (t.uses.length) w.appendChild(section('Where "' + t.name + '" is used', t.uses.length, simpleTable(['Used by', 'Where', 'Attribute or field', 'How'], t.uses.map(function (u) {
58
- return [u.kind, u.where, u.detail || null, u.via.length ? 'through ' + u.via.join(' → ') : 'directly'];
59
- }), 'Uses of the transform')));
60
- }
61
- if (d.unused.length) w.appendChild(section('Used by nothing', d.unused.length, el('p', { className: 'muted', text: d.unused.join(', ') + '. Check rules before deleting: a rule can use a transform in its own code.' })));
62
- w.appendChild(section('All transforms', d.transforms.length, filteredTable(H, d.transforms, ['Transform', 'Type', 'Used directly', 'All uses', 'People'], function (x) {
63
- return [el('button', { className: 'linkbtn', text: x.name, onclick: function () { B.pick = x.name; rerenderHost(); } }), x.type, x.direct, x.uses.length ? x.uses.length : pill('not used', 'lose'), x.people === null ? null : x.people];
64
- }, 'Transforms and their uses')));
65
- }
66
-
67
- // Account create preview
68
- function renderPolicyPreview(w) {
69
- var P = state.bt.policy;
70
- if (!P.sources && !P.loading) {
71
- P.loading = true;
72
- api('/api/build/sources').then(function (r) { P.sources = r; }, function (e) { P.sourcesError = errorText(e); }).then(function () { P.loading = false; if (state.bt.tab === 'policy') renderBuild(); });
73
- }
74
- w.appendChild(el('div', { className: 'note', text: 'What a source\'s create policy would produce for one person, worked out on this computer with the Transform lab engine. Nothing is created. Use it to check a new or changed policy before the next joiner, or why a create failed.' }));
75
- var src = el('select', { className: 'input', style: 'max-width:320px', 'aria-label': 'Source' }, el('option', { value: '', text: P.sourcesError ? 'Could not read sources' : P.sources ? 'Pick a source...' : 'Reading sources...' }));
76
- (P.sources || []).forEach(function (s) { src.appendChild(el('option', { value: s.id, text: s.name })); });
77
- src.value = P.sourceId || '';
78
- src.addEventListener('change', function () { P.sourceId = src.value; });
79
- var use = el('select', { className: 'input', style: 'max-width:160px', 'aria-label': 'Policy' });
80
- ['CREATE', 'UPDATE', 'ENABLE', 'DISABLE', 'CHANGE_PASSWORD'].forEach(function (u) { use.appendChild(el('option', { value: u, text: u === 'CREATE' ? 'Create account' : u.charAt(0) + u.slice(1).toLowerCase().replace('_', ' ') })); });
81
- use.value = P.usageType;
82
- use.addEventListener('change', function () { P.usageType = use.value; });
83
- var who = el('input', { className: 'input', value: P.person, placeholder: 'Username, email or display name', style: 'max-width:280px', 'aria-label': 'Person' });
84
- who.addEventListener('input', function () { P.person = who.value; });
85
- who.addEventListener('keydown', function (e) { if (e.key === 'Enter') go.click(); });
86
- var go = el('button', { className: 'btn primary', disabled: !!P.busy, onclick: function () {
87
- if (!P.sourceId) { toast('Pick a source first'); return; }
88
- if (!P.person.trim()) { toast('Name the person first'); return; }
89
- runJobInto(P, '/api/build/policy/run', { sourceId: P.sourceId, usageType: P.usageType, person: P.person }, renderBuild);
90
- } }, icon('play'), 'Preview');
91
- w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, src, use, who, go));
92
- if (P.busy) { w.appendChild(busyBox(P.busy)); return; }
93
- if (P.error) { w.appendChild(el('div', { className: 'error', text: P.error })); return; }
94
- if (!P.data) return;
95
- var d = P.data;
96
- d.warnings.forEach(function (x) { w.appendChild(el('div', { className: 'banner bad' }, el('span', { text: x }))); });
97
- if (!d.fields.length) return;
98
- w.appendChild(el('p', { className: 'muted', text: d.source + ' · ' + (d.policy || d.usageType) + (d.person ? ' · for ' + d.person.name : '') }));
99
- w.appendChild(section('Fields', d.fields.length, simpleTable(['Field', 'Required', 'Value', 'Result', 'Note'], d.fields.map(function (f) {
100
- return [el('code', { text: f.field }), f.required ? 'yes' : null, f.status === 'ok' || f.status === 'random' ? labValue(f.value) : null,
101
- f.status === 'none' ? pill('not set here', 'keep-other') : f.status === 'hidden' ? pill('hidden', 'keep-other') : labStatus(f.status), f.error || f.note || null];
102
- }), 'Account fields')));
103
- if (d.assumptions.length) w.appendChild(el('div', { className: 'note' }, el('b', { text: 'Assumed: ' }), d.assumptions.join(' · ')));
104
- }
105
-
106
- // Workflow health
107
- function weekBars(weeks) {
108
- var max = Math.max.apply(null, weeks.map(function (x) { return x.runs; }).concat([1]));
109
- var label = weeks.map(function (x, i) { return 'week ' + (i + 1) + ': ' + x.failed + ' failed of ' + x.runs; }).join(', ');
110
- var box = el('span', { className: 'wkbars', role: 'img', 'aria-label': label, title: label });
111
- weeks.forEach(function (x) {
112
- var h = x.runs ? Math.max(3, Math.round(22 * x.runs / max)) : 2;
113
- var bar = el('span', { className: 'wkbar', style: 'height:' + h + 'px' });
114
- if (x.failed) bar.appendChild(el('span', { className: 'wkfail', style: 'height:' + Math.max(2, Math.round(h * x.failed / x.runs)) + 'px' }));
115
- box.appendChild(bar);
116
- });
117
- return box;
118
- }
119
- function renderWorkflowHealth(w) {
120
- var H = state.bt.health;
121
- var days = numSelect(H, 'days', [[7, 'Last 7 days'], [30, 'Last 30 days'], [60, 'Last 60 days'], [90, 'Last 90 days']], 'Period');
122
- w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' },
123
- el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: 'Runs and failures of every workflow per week, and why runs failed, grouped: the same error with different IDs or names counts as one cause.' }),
124
- days, el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/build/health/run', { days: H.days }, rerenderHost); } }, icon('heart'), H.data ? 'Read again' : 'Check workflow health')));
125
- if (H.busy) { w.appendChild(busyBox(H.busy)); return; }
126
- if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }
127
- if (!H.data) return;
128
- var d = H.data, T = d.totals;
129
- (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
130
- var rate = T.runs ? Math.round(1000 * T.failed / T.runs) / 10 : null;
131
- w.appendChild(el('div', { className: 'bigstats' }, stat(T.runs, 'runs'), stat(T.failed, 'failed', T.failed ? 'lose' : undefined), stat(rate, 'failure rate (%)'), stat(T.failingEveryRun, 'fail every run', T.failingEveryRun ? 'lose' : undefined), stat(T.worse, 'failing more this week', T.worse ? 'lose' : undefined), stat(T.quiet, 'enabled, never ran')));
132
- w.appendChild(section('Workflows', d.workflows.length, filteredTable(H, d.workflows, ['Workflow', 'Runs', 'Failed', 'Failure rate', 'Per week (grey: runs, red: failed)', 'Last run', 'Flags', 'Most common cause'], function (x) {
133
- return [el('span', {}, x.name, el('div', { className: 'muted small', text: [x.enabled ? null : 'disabled', x.trigger, x.owner ? 'owner ' + x.owner : null].filter(Boolean).join(' · ') })), x.failedOnly ? '—' : x.runs, x.failed, x.rate === null ? null : x.rate + '%', weekBars(x.weeks), x.lastRun ? x.lastRun.slice(0, 16).replace('T', ' ') + (x.lastStatus ? ' · ' + x.lastStatus : '') : null,
134
- x.flags.length ? el('span', {}, x.flags.map(function (f) { return el('div', {}, pill(f, /Enabled/.test(f) ? 'keep-other' : 'lose')); })) : null, x.topCause || null];
135
- }, 'Workflow health')));
136
- if (d.causes.length) w.appendChild(section('Why runs failed', d.causes.length, simpleTable(['Workflow', 'Step', 'Cause', 'Runs', 'Last'], d.causes.map(function (c) {
137
- return [c.workflow, c.step || null, el('code', { className: 'small', style: 'white-space:pre-wrap;word-break:break-word', text: c.cause }), c.runs, c.last.slice(0, 16).replace('T', ' ')];
138
- }), 'Failure causes')));
139
- }
140
-
141
- // Drift check
142
- function renderDrift(w) {
143
- var D = state.bt.drift;
144
- if (!D.info && !D.loading) {
145
- D.loading = true;
146
- api('/api/build/drift').then(function (r) { D.info = r; }, function (e) { D.infoError = errorText(e); }).then(function () { D.loading = false; if (state.bt.tab === 'drift') rerenderHost(); });
147
- }
148
- w.appendChild(el('div', { className: 'note', text: 'Approve a configuration snapshot as the baseline (for example the day a release went live), then check at any time what changed since: sources, transforms, identity profiles, roles, access profiles and workflows added, removed or changed outside a release. The baseline is kept on this computer.' }));
149
- if (D.infoError) { w.appendChild(el('div', { className: 'error', text: D.infoError })); return; }
150
- if (!D.info) { w.appendChild(busyBox('Reading saved snapshots...')); return; }
151
- var I = D.info;
152
- var reload = function () { D.info = null; rerenderHost(); };
153
- var takeSnap = el('button', { className: 'btn', disabled: !!D.snapBusy, onclick: function () {
154
- D.snapBusy = 'Taking a snapshot...'; rerenderHost();
155
- api('/api/changes/snapshot', 'POST', {}).then(function (r) {
156
- pollJob(r.job, function (p) { D.snapBusy = p; rerenderHost(); }, function () { D.snapBusy = null; toast('Snapshot saved'); reload(); }, function (e) { D.snapBusy = null; toast(e); rerenderHost(); });
157
- }, function (e) { D.snapBusy = null; toast(errorText(e)); rerenderHost(); });
158
- } }, icon('save'), D.snapBusy ? D.snapBusy : 'Take a snapshot now');
159
- if (!I.baseline || D.changing) {
160
- var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: I.baseline ? 'Change the baseline' : 'Approve a baseline' })));
161
- if (!I.days.length) {
162
- card.appendChild(el('p', { className: 'muted', text: 'There is no configuration snapshot yet. Take one now (it reads the configuration; nothing changes in ISC), then approve it.' }));
163
- card.appendChild(el('div', { className: 'bar' }, takeSnap));
164
- } else {
165
- var day = el('select', { className: 'input', style: 'max-width:200px', 'aria-label': 'Snapshot day' });
166
- I.days.forEach(function (x) { day.appendChild(el('option', { value: x, text: x })); });
167
- var note = el('input', { className: 'input', placeholder: 'Note, e.g. Release 2026.12 to production', style: 'max-width:360px', 'aria-label': 'Note' });
168
- card.appendChild(el('div', { className: 'bar' }, day, note,
169
- el('button', { className: 'btn primary', onclick: function () {
170
- api('/api/build/drift/baseline', 'POST', { day: day.value, note: note.value }).then(function () { D.changing = false; D.data = null; toast('Baseline approved'); reload(); }, function (e) { toast(errorText(e)); });
171
- } }, icon('save'), 'Approve as baseline'), takeSnap,
172
- D.changing ? el('button', { className: 'btn', onclick: function () { D.changing = false; rerenderHost(); } }, 'Cancel') : null));
173
- }
174
- w.appendChild(card);
175
- return;
176
- }
177
- var b = I.baseline;
178
- w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Baseline: ' + b.day })),
179
- el('p', { className: 'muted', text: (b.note ? b.note + ' · ' : '') + 'approved by ' + b.by + ' on ' + b.approvedAt.slice(0, 16).replace('T', ' ') }),
180
- el('div', { className: 'bar' },
181
- el('button', { className: 'btn primary', disabled: !!D.busy, onclick: function () { runJobInto(D, '/api/build/drift/run', {}, rerenderHost); } }, icon('cols'), 'Check for drift now'),
182
- el('button', { className: 'btn', onclick: function () { D.changing = true; rerenderHost(); } }, 'Change baseline'),
183
- el('button', { className: 'btn', onclick: function () { api('/api/build/drift/baseline', 'POST', { day: '' }).then(function () { D.data = null; reload(); }); } }, icon('trash'), 'Remove'))));
184
- if (D.busy) { w.appendChild(busyBox(D.busy)); return; }
185
- if (D.error) { w.appendChild(el('div', { className: 'error', text: D.error })); return; }
186
- if (!D.data) return;
187
- var d = D.data, T = d.totals, any = T.added + T.removed + T.changed;
188
- w.appendChild(el('div', { className: 'banner ' + (any ? 'bad' : 'ok') }, el('b', { text: any ? any + ' change' + (any === 1 ? '' : 's') + ' since the baseline' : 'No drift: the configuration matches the baseline' })));
189
- w.appendChild(el('div', { className: 'bigstats' }, stat(T.added, 'added', T.added ? 'lose' : undefined), stat(T.removed, 'removed', T.removed ? 'lose' : undefined), stat(T.changed, 'changed', T.changed ? 'lose' : undefined), stat(T.same, 'unchanged')));
190
- d.kinds.forEach(function (k) {
191
- if (k.error) { w.appendChild(el('div', { className: 'note', text: k.label + ': ' + k.error })); return; }
192
- var n = k.onlyA.length + k.onlyB.length + k.different.length;
193
- if (!n) return;
194
- var body = el('div', {});
195
- if (k.onlyB.length) body.appendChild(el('p', {}, el('b', { text: 'Added: ' }), k.onlyB.join(', ')));
196
- if (k.onlyA.length) body.appendChild(el('p', {}, el('b', { text: 'Removed: ' }), k.onlyA.join(', ')));
197
- if (k.different.length) body.appendChild(simpleTable(['Name', 'Setting', 'At the baseline', 'Now'], k.different.flatMap(function (x) {
198
- return x.differences.map(function (f, i) { return [i ? '' : x.name, el('code', { text: f.path || '(whole object)' }), f.a, f.b]; });
199
- }), k.label + ' changed since the baseline'));
200
- w.appendChild(section(k.label, n, body));
201
- });
202
- w.appendChild(el('div', { className: 'bar', style: 'margin-top:10px' }, downloads(D.job)));
203
- }
1
+ // ---------- Build & test: try changes before making them in ISC (read-only) ----------
2
+ state.bt = { tab: 'tlab', impact: {}, pick: '', policy: { usageType: 'CREATE', person: '' }, health: { days: 30 }, drift: {} };
3
+ // Build & test holds the tools for trying a change before making it. Where transforms and credentials
4
+ // are used and workflow health live on the Tenant page, drift on Audit > Change history, and the role
5
+ // change preview on Role tools: one home each.
6
+ var BUILD_TABS = [
7
+ ['tlab', 'Transform lab', 'sliders'], ['policy', 'Account create preview', 'plus'], ['wlab', 'Workflow lab', 'play'],
8
+ ];
9
+ /** Redraws whichever page the shared tools are on. */
10
+ function rerenderHost() {
11
+ if (state.page === 'tenant') renderTenant();
12
+ else if (state.page === 'certs') renderAudit();
13
+ else renderBuild();
14
+ }
15
+ function renderBuild() {
16
+ var B = state.bt;
17
+ var outer = $('build');
18
+ outer.textContent = '';
19
+ var w = el('div', { className: 'wrap', style: 'max-width:1240px' });
20
+ outer.appendChild(w);
21
+ w.appendChild(el('div', { className: 'rhead', style: 'margin-bottom:4px' }, el('span', { className: 'cat-ico', style: 'color:#6d28d9;background:#ede9fe' }, icon('code')),
22
+ el('div', {}, el('h2', { text: 'Build & test' }), el('p', { className: 'desc', text: 'Try changes before you make them in ISC. Everything here runs on this computer or only reads ISC: nothing is created, changed or started.' }))));
23
+ var tabs = el('div', { className: 'tabs' });
24
+ BUILD_TABS.forEach(function (t) {
25
+ tabs.appendChild(el('button', { className: 'tab' + (B.tab === t[0] ? ' active' : ''), onclick: function () { B.tab = t[0]; renderBuild(); } }, icon(t[2]), t[1]));
26
+ });
27
+ w.appendChild(tabs);
28
+ if (!BUILD_TABS.some(function (t) { return t[0] === B.tab; })) B.tab = 'tlab';
29
+ if (B.tab === 'policy') renderPolicyPreview(w);
30
+ else if (B.tab === 'wlab') renderWorkflowLab(w);
31
+ else renderTransformLab(w);
32
+ w.appendChild(el('p', { className: 'muted small', style: 'margin-top:18px', text: 'Also: where each transform is used (Tenant > Transforms), workflow runs and failures (Tenant > Workflows), where credentials are used (Tenant > Credential map), drift from an approved baseline (Audit > Change history), and who a role change would affect (Role tools > Preview a role change).' }));
33
+ }
34
+
35
+ // Transform impact
36
+ function renderImpactMap(w) {
37
+ var B = state.bt, H = B.impact;
38
+ w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' },
39
+ el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: 'Before you change a transform: every identity profile, other transform and provisioning policy that uses it, also through other transforms, and how many people that covers. Also lists transforms nothing uses.' }),
40
+ el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/build/impact/run', {}, rerenderHost); } }, icon('search'), H.data ? 'Read again' : 'Find where transforms are used')));
41
+ if (H.busy) { w.appendChild(busyBox(H.busy)); return; }
42
+ if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }
43
+ if (!H.data) return;
44
+ var d = H.data;
45
+ (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
46
+ w.appendChild(el('div', { className: 'bigstats' }, stat(d.transforms.length, 'transforms'), stat(d.unused.length, 'used by nothing', d.unused.length ? 'lose' : undefined), stat(d.profiles.length, 'identity profiles'), stat(d.policiesRead, 'provisioning policies read')));
47
+ var pick = el('select', { className: 'input', style: 'max-width:420px', 'aria-label': 'Transform' }, el('option', { value: '', text: 'Pick a transform to see where it is used...' }));
48
+ d.transforms.forEach(function (t) { pick.appendChild(el('option', { value: t.name, text: t.name + ' (' + t.uses.length + ' use' + (t.uses.length === 1 ? '' : 's') + ')' })); });
49
+ pick.value = B.pick;
50
+ pick.addEventListener('change', function () { B.pick = pick.value; rerenderHost(); });
51
+ w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:12px' }, pick));
52
+ var t = d.transforms.filter(function (x) { return x.name === B.pick; })[0];
53
+ if (t) {
54
+ var people = t.people === null ? 'an unknown number of' : fmtNum(t.people);
55
+ w.appendChild(el('div', { className: 'banner ' + (t.uses.length ? 'bad' : 'ok') }, el('b', { text: t.uses.length ? 'Changing "' + t.name + '" affects ' + t.uses.length + ' place' + (t.uses.length === 1 ? '' : 's') : '"' + t.name + '" is not used anywhere IdentityScope can see' }),
56
+ t.uses.length ? el('span', { text: t.people ? ' · identity attributes of ' + people + ' people' : '' }) : null));
57
+ if (t.uses.length) w.appendChild(section('Where "' + t.name + '" is used', t.uses.length, simpleTable(['Used by', 'Where', 'Attribute or field', 'How'], t.uses.map(function (u) {
58
+ return [u.kind, u.where, u.detail || null, u.via.length ? 'through ' + u.via.join(' → ') : 'directly'];
59
+ }), 'Uses of the transform')));
60
+ }
61
+ if (d.unused.length) w.appendChild(section('Used by nothing', d.unused.length, el('p', { className: 'muted', text: d.unused.join(', ') + '. Check rules before deleting: a rule can use a transform in its own code.' })));
62
+ w.appendChild(section('All transforms', d.transforms.length, filteredTable(H, d.transforms, ['Transform', 'Type', 'Used directly', 'All uses', 'People'], function (x) {
63
+ return [el('button', { className: 'linkbtn', text: x.name, onclick: function () { B.pick = x.name; rerenderHost(); } }), x.type, x.direct, x.uses.length ? x.uses.length : pill('not used', 'lose'), x.people === null ? null : x.people];
64
+ }, 'Transforms and their uses')));
65
+ }
66
+
67
+ // Account create preview
68
+ function renderPolicyPreview(w) {
69
+ var P = state.bt.policy;
70
+ if (!P.sources && !P.loading) {
71
+ P.loading = true;
72
+ api('/api/build/sources').then(function (r) { P.sources = r; }, function (e) { P.sourcesError = errorText(e); }).then(function () { P.loading = false; if (state.bt.tab === 'policy') renderBuild(); });
73
+ }
74
+ w.appendChild(el('div', { className: 'note', text: 'What a source\'s create policy would produce for one person, worked out on this computer with the Transform lab engine. Nothing is created. Use it to check a new or changed policy before the next joiner, or why a create failed.' }));
75
+ var src = el('select', { className: 'input', style: 'max-width:320px', 'aria-label': 'Source' }, el('option', { value: '', text: P.sourcesError ? 'Could not read sources' : P.sources ? 'Pick a source...' : 'Reading sources...' }));
76
+ (P.sources || []).forEach(function (s) { src.appendChild(el('option', { value: s.id, text: s.name })); });
77
+ src.value = P.sourceId || '';
78
+ src.addEventListener('change', function () { P.sourceId = src.value; });
79
+ var use = el('select', { className: 'input', style: 'max-width:160px', 'aria-label': 'Policy' });
80
+ ['CREATE', 'UPDATE', 'ENABLE', 'DISABLE', 'CHANGE_PASSWORD'].forEach(function (u) { use.appendChild(el('option', { value: u, text: u === 'CREATE' ? 'Create account' : u.charAt(0) + u.slice(1).toLowerCase().replace('_', ' ') })); });
81
+ use.value = P.usageType;
82
+ use.addEventListener('change', function () { P.usageType = use.value; });
83
+ var who = el('input', { className: 'input', value: P.person, placeholder: 'Username, email or display name', style: 'max-width:280px', 'aria-label': 'Person' });
84
+ who.addEventListener('input', function () { P.person = who.value; });
85
+ who.addEventListener('keydown', function (e) { if (e.key === 'Enter') go.click(); });
86
+ var go = el('button', { className: 'btn primary', disabled: !!P.busy, onclick: function () {
87
+ if (!P.sourceId) { toast('Pick a source first'); return; }
88
+ if (!P.person.trim()) { toast('Name the person first'); return; }
89
+ runJobInto(P, '/api/build/policy/run', { sourceId: P.sourceId, usageType: P.usageType, person: P.person }, renderBuild);
90
+ } }, icon('play'), 'Preview');
91
+ w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, src, use, who, go));
92
+ if (P.busy) { w.appendChild(busyBox(P.busy)); return; }
93
+ if (P.error) { w.appendChild(el('div', { className: 'error', text: P.error })); return; }
94
+ if (!P.data) return;
95
+ var d = P.data;
96
+ d.warnings.forEach(function (x) { w.appendChild(el('div', { className: 'banner bad' }, el('span', { text: x }))); });
97
+ if (!d.fields.length) return;
98
+ w.appendChild(el('p', { className: 'muted', text: d.source + ' · ' + (d.policy || d.usageType) + (d.person ? ' · for ' + d.person.name : '') }));
99
+ w.appendChild(section('Fields', d.fields.length, simpleTable(['Field', 'Required', 'Value', 'Result', 'Note'], d.fields.map(function (f) {
100
+ return [el('code', { text: f.field }), f.required ? 'yes' : null, f.status === 'ok' || f.status === 'random' ? labValue(f.value) : null,
101
+ f.status === 'none' ? pill('not set here', 'keep-other') : f.status === 'hidden' ? pill('hidden', 'keep-other') : labStatus(f.status), f.error || f.note || null];
102
+ }), 'Account fields')));
103
+ if (d.assumptions.length) w.appendChild(el('div', { className: 'note' }, el('b', { text: 'Assumed: ' }), d.assumptions.join(' · ')));
104
+ }
105
+
106
+ // Workflow health
107
+ function weekBars(weeks) {
108
+ var max = Math.max.apply(null, weeks.map(function (x) { return x.runs; }).concat([1]));
109
+ var label = weeks.map(function (x, i) { return 'week ' + (i + 1) + ': ' + x.failed + ' failed of ' + x.runs; }).join(', ');
110
+ var box = el('span', { className: 'wkbars', role: 'img', 'aria-label': label, title: label });
111
+ weeks.forEach(function (x) {
112
+ var h = x.runs ? Math.max(3, Math.round(22 * x.runs / max)) : 2;
113
+ var bar = el('span', { className: 'wkbar', style: 'height:' + h + 'px' });
114
+ if (x.failed) bar.appendChild(el('span', { className: 'wkfail', style: 'height:' + Math.max(2, Math.round(h * x.failed / x.runs)) + 'px' }));
115
+ box.appendChild(bar);
116
+ });
117
+ return box;
118
+ }
119
+ function renderWorkflowHealth(w) {
120
+ var H = state.bt.health;
121
+ var days = numSelect(H, 'days', [[7, 'Last 7 days'], [30, 'Last 30 days'], [60, 'Last 60 days'], [90, 'Last 90 days']], 'Period');
122
+ w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' },
123
+ el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: 'Runs and failures of every workflow per week, and why runs failed, grouped: the same error with different IDs or names counts as one cause.' }),
124
+ days, el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/build/health/run', { days: H.days }, rerenderHost); } }, icon('heart'), H.data ? 'Read again' : 'Check workflow health')));
125
+ if (H.busy) { w.appendChild(busyBox(H.busy)); return; }
126
+ if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }
127
+ if (!H.data) return;
128
+ var d = H.data, T = d.totals;
129
+ (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
130
+ var rate = T.runs ? Math.round(1000 * T.failed / T.runs) / 10 : null;
131
+ w.appendChild(el('div', { className: 'bigstats' }, stat(T.runs, 'runs'), stat(T.failed, 'failed', T.failed ? 'lose' : undefined), stat(rate, 'failure rate (%)'), stat(T.failingEveryRun, 'fail every run', T.failingEveryRun ? 'lose' : undefined), stat(T.worse, 'failing more this week', T.worse ? 'lose' : undefined), stat(T.quiet, 'enabled, never ran')));
132
+ w.appendChild(section('Workflows', d.workflows.length, filteredTable(H, d.workflows, ['Workflow', 'Runs', 'Failed', 'Failure rate', 'Per week (grey: runs, red: failed)', 'Last run', 'Flags', 'Most common cause'], function (x) {
133
+ return [el('span', {}, x.name, el('div', { className: 'muted small', text: [x.enabled ? null : 'disabled', x.trigger, x.owner ? 'owner ' + x.owner : null].filter(Boolean).join(' · ') })), x.failedOnly ? '—' : x.runs, x.failed, x.rate === null ? null : x.rate + '%', weekBars(x.weeks), x.lastRun ? x.lastRun.slice(0, 16).replace('T', ' ') + (x.lastStatus ? ' · ' + x.lastStatus : '') : null,
134
+ x.flags.length ? el('span', {}, x.flags.map(function (f) { return el('div', {}, pill(f, /Enabled/.test(f) ? 'keep-other' : 'lose')); })) : null, x.topCause || null];
135
+ }, 'Workflow health')));
136
+ if (d.causes.length) w.appendChild(section('Why runs failed', d.causes.length, simpleTable(['Workflow', 'Step', 'Cause', 'Runs', 'Last'], d.causes.map(function (c) {
137
+ return [c.workflow, c.step || null, el('code', { className: 'small', style: 'white-space:pre-wrap;word-break:break-word', text: c.cause }), c.runs, c.last.slice(0, 16).replace('T', ' ')];
138
+ }), 'Failure causes')));
139
+ }
140
+
141
+ // Drift check
142
+ function renderDrift(w) {
143
+ var D = state.bt.drift;
144
+ if (!D.info && !D.loading) {
145
+ D.loading = true;
146
+ api('/api/build/drift').then(function (r) { D.info = r; }, function (e) { D.infoError = errorText(e); }).then(function () { D.loading = false; if (state.bt.tab === 'drift') rerenderHost(); });
147
+ }
148
+ w.appendChild(el('div', { className: 'note', text: 'Approve a configuration snapshot as the baseline (for example the day a release went live), then check at any time what changed since: sources, transforms, identity profiles, roles, access profiles and workflows added, removed or changed outside a release. The baseline is kept on this computer.' }));
149
+ if (D.infoError) { w.appendChild(el('div', { className: 'error', text: D.infoError })); return; }
150
+ if (!D.info) { w.appendChild(busyBox('Reading saved snapshots...')); return; }
151
+ var I = D.info;
152
+ var reload = function () { D.info = null; rerenderHost(); };
153
+ var takeSnap = el('button', { className: 'btn', disabled: !!D.snapBusy, onclick: function () {
154
+ D.snapBusy = 'Taking a snapshot...'; rerenderHost();
155
+ api('/api/changes/snapshot', 'POST', {}).then(function (r) {
156
+ pollJob(r.job, function (p) { D.snapBusy = p; rerenderHost(); }, function () { D.snapBusy = null; toast('Snapshot saved'); reload(); }, function (e) { D.snapBusy = null; toast(e); rerenderHost(); });
157
+ }, function (e) { D.snapBusy = null; toast(errorText(e)); rerenderHost(); });
158
+ } }, icon('save'), D.snapBusy ? D.snapBusy : 'Take a snapshot now');
159
+ if (!I.baseline || D.changing) {
160
+ var card = el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: I.baseline ? 'Change the baseline' : 'Approve a baseline' })));
161
+ if (!I.days.length) {
162
+ card.appendChild(el('p', { className: 'muted', text: 'There is no configuration snapshot yet. Take one now (it reads the configuration; nothing changes in ISC), then approve it.' }));
163
+ card.appendChild(el('div', { className: 'bar' }, takeSnap));
164
+ } else {
165
+ var day = el('select', { className: 'input', style: 'max-width:200px', 'aria-label': 'Snapshot day' });
166
+ I.days.forEach(function (x) { day.appendChild(el('option', { value: x, text: x })); });
167
+ var note = el('input', { className: 'input', placeholder: 'Note, e.g. Release 2026.12 to production', style: 'max-width:360px', 'aria-label': 'Note' });
168
+ card.appendChild(el('div', { className: 'bar' }, day, note,
169
+ el('button', { className: 'btn primary', onclick: function () {
170
+ api('/api/build/drift/baseline', 'POST', { day: day.value, note: note.value }).then(function () { D.changing = false; D.data = null; toast('Baseline approved'); reload(); }, function (e) { toast(errorText(e)); });
171
+ } }, icon('save'), 'Approve as baseline'), takeSnap,
172
+ D.changing ? el('button', { className: 'btn', onclick: function () { D.changing = false; rerenderHost(); } }, 'Cancel') : null));
173
+ }
174
+ w.appendChild(card);
175
+ return;
176
+ }
177
+ var b = I.baseline;
178
+ w.appendChild(el('section', { className: 'card' }, el('div', { className: 'card-h' }, el('h3', { text: 'Baseline: ' + b.day })),
179
+ el('p', { className: 'muted', text: (b.note ? b.note + ' · ' : '') + 'approved by ' + b.by + ' on ' + b.approvedAt.slice(0, 16).replace('T', ' ') }),
180
+ el('div', { className: 'bar' },
181
+ el('button', { className: 'btn primary', disabled: !!D.busy, onclick: function () { runJobInto(D, '/api/build/drift/run', {}, rerenderHost); } }, icon('cols'), 'Check for drift now'),
182
+ el('button', { className: 'btn', onclick: function () { D.changing = true; rerenderHost(); } }, 'Change baseline'),
183
+ el('button', { className: 'btn', onclick: function () { api('/api/build/drift/baseline', 'POST', { day: '' }).then(function () { D.data = null; reload(); }); } }, icon('trash'), 'Remove'))));
184
+ if (D.busy) { w.appendChild(busyBox(D.busy)); return; }
185
+ if (D.error) { w.appendChild(el('div', { className: 'error', text: D.error })); return; }
186
+ if (!D.data) return;
187
+ var d = D.data, T = d.totals, any = T.added + T.removed + T.changed;
188
+ w.appendChild(el('div', { className: 'banner ' + (any ? 'bad' : 'ok') }, el('b', { text: any ? any + ' change' + (any === 1 ? '' : 's') + ' since the baseline' : 'No drift: the configuration matches the baseline' })));
189
+ w.appendChild(el('div', { className: 'bigstats' }, stat(T.added, 'added', T.added ? 'lose' : undefined), stat(T.removed, 'removed', T.removed ? 'lose' : undefined), stat(T.changed, 'changed', T.changed ? 'lose' : undefined), stat(T.same, 'unchanged')));
190
+ d.kinds.forEach(function (k) {
191
+ if (k.error) { w.appendChild(el('div', { className: 'note', text: k.label + ': ' + k.error })); return; }
192
+ var n = k.onlyA.length + k.onlyB.length + k.different.length;
193
+ if (!n) return;
194
+ var body = el('div', {});
195
+ if (k.onlyB.length) body.appendChild(el('p', {}, el('b', { text: 'Added: ' }), k.onlyB.join(', ')));
196
+ if (k.onlyA.length) body.appendChild(el('p', {}, el('b', { text: 'Removed: ' }), k.onlyA.join(', ')));
197
+ if (k.different.length) body.appendChild(simpleTable(['Name', 'Setting', 'At the baseline', 'Now'], k.different.flatMap(function (x) {
198
+ return x.differences.map(function (f, i) { return [i ? '' : x.name, el('code', { text: f.path || '(whole object)' }), f.a, f.b]; });
199
+ }), k.label + ' changed since the baseline'));
200
+ w.appendChild(section(k.label, n, body));
201
+ });
202
+ w.appendChild(el('div', { className: 'bar', style: 'margin-top:10px' }, downloads(D.job)));
203
+ }