identityscope 0.28.3 → 0.28.5

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 +914 -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/30-labs.js CHANGED
@@ -1,265 +1,265 @@
1
- // ---------- Transform lab, Workflow lab, Credential map (all read-only; evaluated on this computer) ----------
2
- var LAB_SAMPLE_TRANSFORM = { type: 'static', attributes: { fn: { type: 'identityAttribute', attributes: { name: 'firstname' } }, ln: { type: 'identityAttribute', attributes: { name: 'lastname' } }, value: '$fn.substring(0,1).toLowerCase()$ln.toLowerCase()' } };
3
- var LAB_SAMPLE_TRIGGER = { identity: { id: 'id-1', name: 'jane.doe' }, changes: [{ attribute: 'cloudLifecycleState', oldValue: 'active', newValue: 'inactive' }] };
4
- function labState() {
5
- if (!state.lab) state.lab = {
6
- t: { json: JSON.stringify(LAB_SAMPLE_TRANSFORM, null, 2), name: '', implicit: '', identity: JSON.stringify(LAB_IDENTITY, null, 2), accounts: JSON.stringify([LAB_HR_ACCOUNT], null, 2), drafts: '', result: null, cases: [], people: {}, count: 200, query: '', attribute: '' },
7
- w: { json: '', trigger: JSON.stringify(LAB_SAMPLE_TRIGGER, null, 2), mocks: '{}', pick: '', result: null, replay: {} },
8
- c: {},
9
- };
10
- return state.lab;
11
- }
12
- function labCode(value, label, rows, oninput) {
13
- var ta = el('textarea', { className: 'yaml', spellcheck: 'false', 'aria-label': label, style: 'min-height:' + (rows * 20 + 28) + 'px' });
14
- ta.value = value;
15
- ta.addEventListener('input', function () { oninput(ta.value); });
16
- return ta;
17
- }
18
- function labParse(text, what) {
19
- if (!String(text).trim()) return undefined;
20
- try { return JSON.parse(text); } catch (e) { throw new Error(what + ' is not valid JSON: ' + e.message); }
21
- }
22
- function labValue(v) {
23
- if (v === null || v === undefined) return el('span', { className: 'muted', text: 'null (no value)' });
24
- return el('code', { text: typeof v === 'string' ? v : JSON.stringify(v) });
25
- }
26
- var LAB_STATUS = { ok: ['worked offline', 'gain'], error: ['fails (ISC would fail too)', 'lose'], 'isc-only': ['only ISC can work this out', 'keep-other'], random: ['different every run', 'keep-other'] };
27
- function labStatus(s) { var x = LAB_STATUS[s] || [s, 'keep-other']; return pill(x[0], x[1]); }
28
- function labLoadTenant(H, path, rerender) {
29
- if (H.list || H.loading) return;
30
- H.loading = true;
31
- api(path).then(function (r) { H.list = r; }, function (e) { H.listError = errorText(e); }).then(function () { H.loading = false; rerender(); });
32
- }
33
-
34
- // Tenant > Transform lab
35
- function renderTransformLab(w) {
36
- var L = labState().t, rr = renderBuild;
37
- labLoadTenant(L, '/api/lab/transforms', rr);
38
- w.appendChild(el('div', { className: 'note', text: 'Runs the transform on this computer, nothing is saved to ISC. Pick one of your transforms or identity profile mappings, or paste a draft. Velocity, dates and lookups work the way SailPoint documents them; anything only ISC can know (custom rules, uniqueness) is marked.' }));
39
- var pick = el('select', { className: 'input', style: 'max-width:420px', 'aria-label': 'Start from' }, el('option', { value: '', text: L.listError ? 'Could not read transforms' : L.list ? 'Start from one of yours...' : 'Reading your transforms...' }));
40
- if (L.list) {
41
- var g1 = el('optgroup', { label: 'Identity profile mappings' });
42
- L.list.mappings.forEach(function (m, i) { g1.appendChild(el('option', { value: 'm' + i, text: m.profile + ': ' + m.attribute + ' (' + m.summary + ')' })); });
43
- var g2 = el('optgroup', { label: 'Transforms' });
44
- L.list.transforms.forEach(function (t, i) { g2.appendChild(el('option', { value: 't' + i, text: t.name + ' (' + t.type + ')' })); });
45
- pick.appendChild(g1); pick.appendChild(g2);
46
- }
47
- pick.addEventListener('change', function () {
48
- var v = pick.value; if (!v) return;
49
- if (v[0] === 'm') { var m = L.list.mappings[Number(v.slice(1))]; L.json = JSON.stringify(m.transformDefinition, null, 2); L.name = m.profile + ' / ' + m.attribute; L.attribute = m.attribute; }
50
- else { var t = L.list.transforms[Number(v.slice(1))]; L.json = JSON.stringify({ type: t.type, attributes: t.attributes || {} }, null, 2); L.name = t.name; L.attribute = ''; }
51
- L.help = ''; L.result = null; L.people = {}; L.cases = (L.saved && L.saved[L.name]) || [];
52
- rr();
53
- });
54
- if (!L.saved) api('/api/lab/tests').then(function (r) { L.saved = r; }, function () { L.saved = {}; });
55
- var nameIn = el('input', { className: 'input', value: L.name, placeholder: 'Name (for saved test cases)', style: 'max-width:260px', 'aria-label': 'Transform name' });
56
- nameIn.addEventListener('input', function () { L.name = nameIn.value; });
57
- var exPick = el('select', { className: 'input', style: 'max-width:320px', 'aria-label': 'Examples' }, el('option', { value: '', text: 'Or start from an example...' }));
58
- TRANSFORM_EXAMPLES.forEach(function (x, i) { exPick.appendChild(el('option', { value: String(i), text: x.title })); });
59
- exPick.addEventListener('change', function () {
60
- var x = TRANSFORM_EXAMPLES[Number(exPick.value)]; if (!x) return;
61
- L.json = JSON.stringify(x.transform, null, 2); L.name = x.title; L.attribute = '';
62
- L.implicit = x.implicit || ''; L.identity = JSON.stringify(x.identity || LAB_IDENTITY, null, 2);
63
- L.accounts = JSON.stringify(x.accounts || [], null, 2); L.drafts = x.drafts ? JSON.stringify(x.drafts, null, 2) : '';
64
- L.help = x.help; L.result = null; L.people = {}; L.cases = [];
65
- rr();
66
- });
67
- w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:10px' }, pick, exPick, nameIn));
68
- if (L.help) w.appendChild(el('div', { className: 'note' }, el('b', { text: 'About this example: ' }), L.help));
69
-
70
- var runBtn = el('button', { className: 'btn primary', onclick: function () { labRunTransform(L, rr); } }, icon('play'), 'Run');
71
- var left = el('div', { style: 'flex:1.2;min-width:340px' }, el('div', { className: 'lbl', text: 'Transform (JSON)' }), labCode(L.json, 'Transform JSON', 16, function (v) { L.json = v; }));
72
- var imp = el('input', { className: 'input', value: L.implicit, placeholder: 'e.g. 2024-03-01 or Sales', 'aria-label': 'Input value' });
73
- imp.addEventListener('input', function () { L.implicit = imp.value; });
74
- var right = el('div', { style: 'flex:1;min-width:300px' },
75
- el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Input value (what the identity profile mapping passes in)' }), imp),
76
- el('div', { className: 'lbl', text: 'Identity attributes (JSON)' }), labCode(L.identity, 'Identity attributes JSON', 4, function (v) { L.identity = v; }),
77
- el('div', { className: 'lbl', style: 'margin-top:10px', text: 'Accounts (JSON list; used by accountAttribute)' }), labCode(L.accounts, 'Accounts JSON', 7, function (v) { L.accounts = v; }),
78
- el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'Each account: "source" (the source name the transform asks for), "attributes" (the account\'s attributes); optional "nativeIdentity", "name" and "created", which accountFilter and the oldest-first rule use.' }),
79
- el('div', { className: 'lbl', style: 'margin-top:10px', text: 'Other transforms (JSON list; used by reference)' }), labCode(L.drafts, 'Other transforms JSON', 4, function (v) { L.drafts = v; }),
80
- el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'Drafts with a "name", "type" and "attributes". A reference looks here first, then in your tenant\'s saved transforms, so you can test a chain before saving any of it.' }),
81
- el('div', { className: 'bar', style: 'margin-top:10px' }, runBtn));
82
- w.appendChild(el('div', { style: 'display:flex;gap:16px;flex-wrap:wrap;margin-bottom:14px' }, left, right));
83
-
84
- if (L.error) w.appendChild(el('div', { className: 'error', text: L.error }));
85
- var R = L.result;
86
- if (R) {
87
- var r = R.result;
88
- w.appendChild(section('Result', null, el('div', {},
89
- el('div', { className: 'bar', style: 'margin-bottom:10px' }, el('b', { text: 'Value: ' }), labValue(r.value), labStatus(r.status)),
90
- r.error ? el('div', { className: 'error', text: r.error }) : null,
91
- r.assumptions.length ? el('div', { className: 'note' }, el('b', { text: 'Assumed where SailPoint does not document it: ' }), r.assumptions.join(' · ')) : null,
92
- simpleTable(['Step', 'Transform', 'Input', 'Output', 'Note'], r.trace.map(function (s) {
93
- return [el('span', { style: 'padding-left:' + (s.depth * 14) + 'px', text: s.type }), s.name || null, s.input === undefined ? null : labValue(s.input), s.error ? pill(s.error, 'lose') : labValue(s.output), s.note || null];
94
- }), 'How the value was worked out'))));
95
- }
96
- renderLabCases(w, L, rr);
97
- renderLabPeople(w, L, rr);
98
- }
99
- function labInput(L, implicit) {
100
- var input = { implicit: implicit === undefined ? (L.implicit === '' ? undefined : L.implicit) : implicit };
101
- var id = labParse(L.identity, 'Identity attributes'); if (id) input.identity = id;
102
- var ac = labParse(L.accounts, 'Accounts'); if (ac) input.accounts = ac;
103
- return input;
104
- }
105
- function labRunTransform(L, rr) {
106
- L.error = null;
107
- try {
108
- var tr = labParse(L.json, 'The transform');
109
- var cases = L.cases.map(function (c) { return { name: c.name, expected: c.expected, input: labInput(L, c.implicit) }; });
110
- api('/api/lab/transform/run', 'POST', { transform: tr, input: labInput(L), cases: cases, transforms: labParse(L.drafts, 'Other transforms') }).then(function (r) {
111
- L.result = r;
112
- (r.cases || []).forEach(function (x, i) { if (L.cases[i]) L.cases[i].last = x; });
113
- }, function (e) { L.error = errorText(e); }).then(rr);
114
- } catch (e) { L.error = e.message; rr(); }
115
- }
116
- function renderLabCases(w, L, rr) {
117
- var addBtn = el('button', { className: 'btn sm', onclick: function () {
118
- var got = L.result && L.result.result.value;
119
- L.cases.push({ name: 'Case ' + (L.cases.length + 1), implicit: L.implicit, expected: got === null || got === undefined ? '' : String(got) });
120
- rr();
121
- } }, icon('plus'), 'Add the current input as a case');
122
- var saveBtn = el('button', { className: 'btn sm', disabled: !L.name, onclick: function () {
123
- api('/api/lab/tests', 'POST', { transform: L.name, cases: L.cases.map(function (c) { return { name: c.name, implicit: c.implicit, expected: c.expected }; }) }).then(function (r) { L.saved = r; toast('Test cases saved on this computer'); }, function (e) { toast(errorText(e)); });
124
- } }, icon('save'), 'Save cases');
125
- var passed = L.cases.filter(function (c) { return c.last && c.last.pass; }).length, ran = L.cases.filter(function (c) { return c.last; }).length;
126
- var body = el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:10px' }, addBtn, saveBtn, el('span', { className: 'muted small', text: L.name ? 'Saved for "' + L.name + '" in your IdentityScope folder.' : 'Give the transform a name to save its cases.' }), el('span', { style: 'flex:1' }), ran ? pill(passed + ' of ' + ran + ' pass', passed === ran ? 'gain' : 'lose') : null));
127
- if (L.cases.length) {
128
- body.appendChild(simpleTable(['Case', 'Input value', 'Expected', 'Got', ''], L.cases.map(function (c, i) {
129
- var n = el('input', { className: 'input', value: c.name, 'aria-label': 'Case name ' + (i + 1) }); n.addEventListener('input', function () { c.name = n.value; });
130
- var v = el('input', { className: 'input', value: c.implicit || '', 'aria-label': 'Case input ' + (i + 1) }); v.addEventListener('input', function () { c.implicit = v.value; });
131
- var x = el('input', { className: 'input', value: c.expected || '', 'aria-label': 'Expected value ' + (i + 1) }); x.addEventListener('input', function () { c.expected = x.value; });
132
- return [n, v, x, c.last ? el('span', {}, pill(c.last.pass ? 'pass' : 'fail', c.last.pass ? 'gain' : 'lose'), ' ', el('code', { text: c.last.got })) : null,
133
- el('button', { className: 'btn sm', 'aria-label': 'Remove case ' + (i + 1), onclick: function () { L.cases.splice(i, 1); rr(); } }, icon('trash'))];
134
- }), 'Test cases'));
135
- body.appendChild(el('p', { className: 'muted small', text: 'Cases use the identity attributes and accounts above with their own input value. Run checks every case.' }));
136
- }
137
- w.appendChild(section('Test cases', L.cases.length, body));
138
- }
139
- function renderLabPeople(w, L, rr) {
140
- var H = L.people;
141
- var count = numSelect(L, 'count', [[50, '50 people'], [200, '200 people'], [500, '500 people'], [2000, '2,000 people']], 'How many people');
142
- var q = attrInput(L, 'query', 'Which people (search query, optional)', 'attributes.department:Sales');
143
- var at = attrInput(L, 'attribute', 'Compare with identity attribute (optional)', 'email');
144
- var go = el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () {
145
- try { runJobInto(H, '/api/lab/transform/people', { transform: labParse(L.json, 'The transform'), transforms: labParse(L.drafts, 'Other transforms'), attribute: L.attribute || undefined, query: L.query || undefined, count: L.count }, rr); } catch (e) { toast(e.message); }
146
- } }, icon('people'), 'Run on real people');
147
- var body = el('div', {}, el('p', { className: 'muted', text: 'Reads real people and their accounts from ISC and works the value out for each, on this computer. With an attribute to compare, it shows where the offline result differs from what ISC holds now: use it before changing a mapping, or to check this engine against your tenant.' }),
148
- el('div', { className: 'bar', style: 'margin-bottom:12px;align-items:flex-end' }, q, at, el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'How many' }), count), go));
149
- if (H.busy) body.appendChild(busyBox(H.busy));
150
- if (H.error) body.appendChild(el('div', { className: 'error', text: H.error }));
151
- if (H.data) {
152
- var d = H.data, S = d.summary;
153
- (d.notes || []).forEach(function (n) { body.appendChild(el('div', { className: 'note', text: n })); });
154
- body.appendChild(el('div', { className: 'bigstats' }, d.attribute ? stat(S.same, 'same as ISC') : null, d.attribute ? stat(S.different, 'different from ISC', 'lose') : null, stat(S.empty, 'no value'), stat(S.errors, 'errors', 'lose'), stat(S.iscOnly + S.random, 'only ISC can say'), stat(d.people, 'people')));
155
- if (d.distinct.length) body.appendChild(el('p', { className: 'muted small', text: 'Most common results: ' + d.distinct.slice(0, 8).map(function (x) { return (x.value || '(empty)') + ' × ' + x.people; }).join(', ') }));
156
- var show = d.attribute ? d.rows.slice().sort(function (a, b) { return (a.same === false ? 0 : 1) - (b.same === false ? 0 : 1); }) : d.rows;
157
- body.appendChild(filteredTable(H, show, ['Person', d.attribute ? 'In ISC now' : 'Current', 'Offline result', 'Result'], function (r) {
158
- return [r.person, r.current === undefined ? null : labValue(r.current), labValue(r.result), r.status !== 'ok' ? labStatus(r.status) : d.attribute ? pill(r.same ? 'same' : 'different', r.same ? 'gain' : 'lose') : null];
159
- }, 'Transform results per person'));
160
- }
161
- w.appendChild(section('Try it on real people', null, body));
162
- }
163
-
164
- // Tenant > Workflow lab
165
- function renderWorkflowLab(w) {
166
- var L = labState().w, rr = renderBuild;
167
- labLoadTenant(L, '/api/lab/workflows', rr);
168
- w.appendChild(el('div', { className: 'note', text: 'Walks a workflow step by step on this computer with a trigger you give it: which branch each condition takes, what each variable becomes and what each action would send. Nothing is called, so the workflow does not need to be disabled. Secrets are never shown.' }));
169
- var pick = el('select', { className: 'input', style: 'max-width:420px', 'aria-label': 'Workflow' }, el('option', { value: '', text: L.listError ? 'Could not read workflows' : L.list ? 'Pick one of your workflows...' : 'Reading your workflows...' }));
170
- (L.list || []).forEach(function (x) { pick.appendChild(el('option', { value: x.id, text: x.name + (x.enabled ? '' : ' (disabled)') })); });
171
- pick.value = L.pick;
172
- pick.addEventListener('change', function () {
173
- L.pick = pick.value;
174
- var x = (L.list || []).filter(function (y) { return y.id === L.pick; })[0];
175
- if (x) L.json = JSON.stringify(x.definition || {}, null, 2);
176
- L.help = '';
177
- L.result = null; L.replay = {}; rr();
178
- });
179
- var exPick = el('select', { className: 'input', style: 'max-width:360px', 'aria-label': 'Workflow examples' }, el('option', { value: '', text: 'Or start from an example...' }));
180
- WORKFLOW_EXAMPLES.forEach(function (x, i) { exPick.appendChild(el('option', { value: String(i), text: x.title })); });
181
- exPick.addEventListener('change', function () {
182
- var x = WORKFLOW_EXAMPLES[Number(exPick.value)]; if (!x) return;
183
- L.pick = ''; L.json = JSON.stringify(x.definition, null, 2); L.trigger = JSON.stringify(TRIGGER_SAMPLES[x.trigger].input, null, 2);
184
- L.mocks = JSON.stringify(x.mocks || {}, null, 2); L.help = x.help; L.result = null; L.replay = {};
185
- rr();
186
- });
187
- var trPick = el('select', { className: 'input', style: 'max-width:280px', 'aria-label': 'Trigger input samples' }, el('option', { value: '', text: 'Trigger input sample...' }));
188
- TRIGGER_SAMPLES.forEach(function (x, i) { trPick.appendChild(el('option', { value: String(i), text: x.title })); });
189
- trPick.addEventListener('change', function () { var x = TRIGGER_SAMPLES[Number(trPick.value)]; if (!x) return; L.trigger = JSON.stringify(x.input, null, 2); L.result = null; rr(); });
190
- w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:10px' }, pick, exPick, trPick));
191
- if (L.help) w.appendChild(el('div', { className: 'note' }, el('b', { text: 'About this example: ' }), L.help));
192
- var runBtn = el('button', { className: 'btn primary', onclick: function () {
193
- L.error = null;
194
- try {
195
- api('/api/lab/workflow/simulate', 'POST', { definition: labParse(L.json, 'The definition'), trigger: labParse(L.trigger, 'The trigger') || {}, mocks: labParse(L.mocks, 'Step outputs') || {} }).then(function (r) { L.result = r; }, function (e) { L.error = errorText(e); }).then(rr);
196
- } catch (e) { L.error = e.message; rr(); }
197
- } }, icon('play'), 'Simulate');
198
- w.appendChild(el('div', { style: 'display:flex;gap:16px;flex-wrap:wrap;margin-bottom:14px' },
199
- el('div', { style: 'flex:1.2;min-width:340px' }, el('div', { className: 'lbl', text: 'Definition (JSON: "start" and "steps")' }), labCode(L.json, 'Workflow definition JSON', 16, function (v) { L.json = v; })),
200
- el('div', { style: 'flex:1;min-width:300px' }, el('div', { className: 'lbl', text: 'Trigger input (JSON)' }), labCode(L.trigger, 'Trigger JSON', 8, function (v) { L.trigger = v; }),
201
- el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'What the trigger passes in; steps read it as $.trigger. Pick a sample above for the shape SailPoint documents per trigger, or replay a real run to use its actual input.' }),
202
- el('div', { className: 'lbl', style: 'margin-top:10px', text: 'Step outputs to pretend (JSON: step name → output, optional)' }), labCode(L.mocks, 'Step outputs JSON', 4, function (v) { L.mocks = v; }),
203
- el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'For steps that would read ISC or call a system, e.g. {"Get Identity": {"attributes": {"manager": {"email": "x@acme.com"}}}}. Later steps read it as $.getIdentity (the step name in camel case).' }),
204
- el('div', { className: 'bar', style: 'margin-top:10px' }, runBtn))));
205
- if (L.error) w.appendChild(el('div', { className: 'error', text: L.error }));
206
- var R = L.result;
207
- if (R) {
208
- var tone = R.outcome === 'success' ? 'ok' : 'bad';
209
- w.appendChild(el('div', { className: 'banner ' + tone }, el('b', { text: 'Ends in ' + R.outcome + (R.endStep ? ' at "' + R.endStep + '"' : '') }), el('span', { text: R.path.join(' → ') })));
210
- R.warnings.forEach(function (x) { w.appendChild(el('div', { className: 'note', text: x })); });
211
- if (R.failure) w.appendChild(el('div', { className: 'error', text: R.failure }));
212
- w.appendChild(section('Steps', R.steps.length, simpleTable(['Step', 'Kind', 'What happens', 'Details', 'Next'], R.steps.map(function (s) {
213
- var details = s.resolved !== undefined ? s.resolved : s.output;
214
- return [el('span', { style: 'padding-left:' + (s.depth * 14) + 'px', text: s.step }), s.kind + (s.mocked ? ' (' + s.mocked + ' output)' : ''), el('span', {}, s.note || '', s.warning ? el('div', {}, pill(s.warning, 'lose')) : null), details === undefined ? null : el('code', { className: 'small', style: 'white-space:pre-wrap;word-break:break-word', text: JSON.stringify(details) }), s.next || null];
215
- }), 'Simulated steps')));
216
- }
217
- renderReplay(w, L, rr);
218
- }
219
- function renderReplay(w, L, rr) {
220
- var H = L.replay;
221
- if (!L.replayCount) L.replayCount = 20;
222
- var count = numSelect(L, 'replayCount', [[10, 'Last 10 runs'], [20, 'Last 20 runs'], [50, 'Last 50 runs'], [100, 'Last 100 runs']], 'How many runs');
223
- var go = function (draft) {
224
- return function () {
225
- try { runJobInto(H, '/api/lab/workflow/replay', { workflowId: L.pick, count: L.replayCount, definition: draft ? labParse(L.json, 'The definition') : undefined }, rr); } catch (e) { toast(e.message); }
226
- };
227
- };
228
- var body = el('div', {}, el('p', { className: 'muted', text: 'Reads the history of real runs (ISC keeps it for 90 days) and runs each one again here. "As it ran" checks the simulator against ISC. "With my edits" uses the definition above, so you can see which real runs would now take a different path before you publish.' }),
229
- el('div', { className: 'bar', style: 'margin-bottom:12px' }, count,
230
- el('button', { className: 'btn primary', disabled: !L.pick || !!H.busy, onclick: go(false) }, icon('lifecycle'), 'Replay as it ran'),
231
- el('button', { className: 'btn', disabled: !L.pick || !!H.busy, onclick: go(true) }, icon('play'), 'Replay with my edits'),
232
- L.pick ? null : el('span', { className: 'muted small', text: 'Pick one of your workflows first.' })));
233
- if (H.busy) body.appendChild(busyBox(H.busy));
234
- if (H.error) body.appendChild(el('div', { className: 'error', text: H.error }));
235
- if (H.data) {
236
- var d = H.data;
237
- (d.notes || []).forEach(function (n) { body.appendChild(el('div', { className: 'note', text: n })); });
238
- body.appendChild(el('div', { className: 'bigstats' }, stat(d.same, d.draft ? 'would take the same path' : 'same path as ISC'), stat(d.total - d.same, d.draft ? 'would take a different path' : 'different from ISC', 'lose'), stat(d.total, 'runs replayed')));
239
- body.appendChild(filteredTable(H, d.results, ['Started', 'Status in ISC', 'Path in ISC', d.draft ? 'Path with your edits' : 'Simulated path', 'Result'], function (x) {
240
- return [x.started ? x.started.slice(0, 16).replace('T', ' ') : null, x.status || null, x.realPath.join(' → '), x.simPath.join(' → '), x.same ? pill('same', 'gain') : pill(x.noTrigger ? 'no trigger recorded' : 'different at step ' + ((x.divergence && x.divergence.index + 1) || '?'), 'lose')];
241
- }, 'Replayed runs'));
242
- }
243
- w.appendChild(section('Replay real runs', null, body));
244
- }
245
-
246
- // Tenant > Credential map
247
- function renderCredentialMap(w) {
248
- var H = labState().c, rr = rerenderHost;
249
- w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: 'Every place a client ID, user or endpoint is used in workflows and source connections: a checklist for rotating a secret or promoting to production. Secret values are never read or shown; only whether one is typed in.' }),
250
- el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/lab/credentials/run', {}, rr); } }, icon('search'), H.data ? 'Read again' : 'Map credentials')));
251
- if (H.busy) { w.appendChild(busyBox(H.busy)); return; }
252
- if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }
253
- if (!H.data) return;
254
- var d = H.data, T = d.totals;
255
- (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
256
- w.appendChild(el('div', { className: 'bigstats' }, stat(T.inline, 'secrets typed into a step or source', 'lose'), stat(T.otherTenant, 'calls to another ISC tenant', T.otherTenant ? 'lose' : undefined), stat(T.thisTenantByName, 'call this tenant by its name (break when promoted)', T.thisTenantByName ? 'lose' : undefined), stat(T.parameterStorage, 'use Parameter Storage'), stat(T.workflowSteps, 'workflow steps with a connection'), stat(T.sources, 'sources with a connection')));
257
- w.appendChild(section('By credential', d.groups.length, simpleTable(['Target', 'Client ID or user', 'Uses', 'Workflows', 'Sources', 'Secret typed in'], d.groups.map(function (g) {
258
- return [g.target || '—', g.clientId || g.user || '—', g.uses, g.workflows, g.sources, g.inline ? pill(String(g.inline), 'lose') : 0];
259
- }), 'Credentials grouped by target')));
260
- w.appendChild(section('Every use', d.uses.length, filteredTable(H, d.uses, ['Where', 'Name', 'Step', 'Target', 'Client ID or user', 'Secret kept as', 'Notes'], function (u) {
261
- return [u.where, el('span', {}, u.object, u.objectEnabled === false ? el('div', { className: 'muted small', text: 'disabled' }) : null), u.step || null, u.target || null, u.clientId || u.user || null,
262
- u.parameterStorage ? pill('Parameter Storage', 'gain') : u.hasSecret ? pill('typed in', 'lose') : 'none', u.flags.length ? el('span', {}, u.flags.map(function (f) { return el('div', { className: 'small', text: f }); })) : null];
263
- }, 'Credential uses')));
264
- w.appendChild(el('p', { className: 'muted small', text: 'To rotate: change the secret in the application, then update each place listed here in ISC (or once, in Parameter Storage, for steps that use it). IdentityScope stays read-only and does not change them for you.' }));
265
- }
1
+ // ---------- Transform lab, Workflow lab, Credential map (all read-only; evaluated on this computer) ----------
2
+ var LAB_SAMPLE_TRANSFORM = { type: 'static', attributes: { fn: { type: 'identityAttribute', attributes: { name: 'firstname' } }, ln: { type: 'identityAttribute', attributes: { name: 'lastname' } }, value: '$fn.substring(0,1).toLowerCase()$ln.toLowerCase()' } };
3
+ var LAB_SAMPLE_TRIGGER = { identity: { id: 'id-1', name: 'jane.doe' }, changes: [{ attribute: 'cloudLifecycleState', oldValue: 'active', newValue: 'inactive' }] };
4
+ function labState() {
5
+ if (!state.lab) state.lab = {
6
+ t: { json: JSON.stringify(LAB_SAMPLE_TRANSFORM, null, 2), name: '', implicit: '', identity: JSON.stringify(LAB_IDENTITY, null, 2), accounts: JSON.stringify([LAB_HR_ACCOUNT], null, 2), drafts: '', result: null, cases: [], people: {}, count: 200, query: '', attribute: '' },
7
+ w: { json: '', trigger: JSON.stringify(LAB_SAMPLE_TRIGGER, null, 2), mocks: '{}', pick: '', result: null, replay: {} },
8
+ c: {},
9
+ };
10
+ return state.lab;
11
+ }
12
+ function labCode(value, label, rows, oninput) {
13
+ var ta = el('textarea', { className: 'yaml', spellcheck: 'false', 'aria-label': label, style: 'min-height:' + (rows * 20 + 28) + 'px' });
14
+ ta.value = value;
15
+ ta.addEventListener('input', function () { oninput(ta.value); });
16
+ return ta;
17
+ }
18
+ function labParse(text, what) {
19
+ if (!String(text).trim()) return undefined;
20
+ try { return JSON.parse(text); } catch (e) { throw new Error(what + ' is not valid JSON: ' + e.message); }
21
+ }
22
+ function labValue(v) {
23
+ if (v === null || v === undefined) return el('span', { className: 'muted', text: 'null (no value)' });
24
+ return el('code', { text: typeof v === 'string' ? v : JSON.stringify(v) });
25
+ }
26
+ var LAB_STATUS = { ok: ['worked offline', 'gain'], error: ['fails (ISC would fail too)', 'lose'], 'isc-only': ['only ISC can work this out', 'keep-other'], random: ['different every run', 'keep-other'] };
27
+ function labStatus(s) { var x = LAB_STATUS[s] || [s, 'keep-other']; return pill(x[0], x[1]); }
28
+ function labLoadTenant(H, path, rerender) {
29
+ if (H.list || H.loading) return;
30
+ H.loading = true;
31
+ api(path).then(function (r) { H.list = r; }, function (e) { H.listError = errorText(e); }).then(function () { H.loading = false; rerender(); });
32
+ }
33
+
34
+ // Tenant > Transform lab
35
+ function renderTransformLab(w) {
36
+ var L = labState().t, rr = renderBuild;
37
+ labLoadTenant(L, '/api/lab/transforms', rr);
38
+ w.appendChild(el('div', { className: 'note', text: 'Runs the transform on this computer, nothing is saved to ISC. Pick one of your transforms or identity profile mappings, or paste a draft. Velocity, dates and lookups work the way SailPoint documents them; anything only ISC can know (custom rules, uniqueness) is marked.' }));
39
+ var pick = el('select', { className: 'input', style: 'max-width:420px', 'aria-label': 'Start from' }, el('option', { value: '', text: L.listError ? 'Could not read transforms' : L.list ? 'Start from one of yours...' : 'Reading your transforms...' }));
40
+ if (L.list) {
41
+ var g1 = el('optgroup', { label: 'Identity profile mappings' });
42
+ L.list.mappings.forEach(function (m, i) { g1.appendChild(el('option', { value: 'm' + i, text: m.profile + ': ' + m.attribute + ' (' + m.summary + ')' })); });
43
+ var g2 = el('optgroup', { label: 'Transforms' });
44
+ L.list.transforms.forEach(function (t, i) { g2.appendChild(el('option', { value: 't' + i, text: t.name + ' (' + t.type + ')' })); });
45
+ pick.appendChild(g1); pick.appendChild(g2);
46
+ }
47
+ pick.addEventListener('change', function () {
48
+ var v = pick.value; if (!v) return;
49
+ if (v[0] === 'm') { var m = L.list.mappings[Number(v.slice(1))]; L.json = JSON.stringify(m.transformDefinition, null, 2); L.name = m.profile + ' / ' + m.attribute; L.attribute = m.attribute; }
50
+ else { var t = L.list.transforms[Number(v.slice(1))]; L.json = JSON.stringify({ type: t.type, attributes: t.attributes || {} }, null, 2); L.name = t.name; L.attribute = ''; }
51
+ L.help = ''; L.result = null; L.people = {}; L.cases = (L.saved && L.saved[L.name]) || [];
52
+ rr();
53
+ });
54
+ if (!L.saved) api('/api/lab/tests').then(function (r) { L.saved = r; }, function () { L.saved = {}; });
55
+ var nameIn = el('input', { className: 'input', value: L.name, placeholder: 'Name (for saved test cases)', style: 'max-width:260px', 'aria-label': 'Transform name' });
56
+ nameIn.addEventListener('input', function () { L.name = nameIn.value; });
57
+ var exPick = el('select', { className: 'input', style: 'max-width:320px', 'aria-label': 'Examples' }, el('option', { value: '', text: 'Or start from an example...' }));
58
+ TRANSFORM_EXAMPLES.forEach(function (x, i) { exPick.appendChild(el('option', { value: String(i), text: x.title })); });
59
+ exPick.addEventListener('change', function () {
60
+ var x = TRANSFORM_EXAMPLES[Number(exPick.value)]; if (!x) return;
61
+ L.json = JSON.stringify(x.transform, null, 2); L.name = x.title; L.attribute = '';
62
+ L.implicit = x.implicit || ''; L.identity = JSON.stringify(x.identity || LAB_IDENTITY, null, 2);
63
+ L.accounts = JSON.stringify(x.accounts || [], null, 2); L.drafts = x.drafts ? JSON.stringify(x.drafts, null, 2) : '';
64
+ L.help = x.help; L.result = null; L.people = {}; L.cases = [];
65
+ rr();
66
+ });
67
+ w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:10px' }, pick, exPick, nameIn));
68
+ if (L.help) w.appendChild(el('div', { className: 'note' }, el('b', { text: 'About this example: ' }), L.help));
69
+
70
+ var runBtn = el('button', { className: 'btn primary', onclick: function () { labRunTransform(L, rr); } }, icon('play'), 'Run');
71
+ var left = el('div', { style: 'flex:1.2;min-width:340px' }, el('div', { className: 'lbl', text: 'Transform (JSON)' }), labCode(L.json, 'Transform JSON', 16, function (v) { L.json = v; }));
72
+ var imp = el('input', { className: 'input', value: L.implicit, placeholder: 'e.g. 2024-03-01 or Sales', 'aria-label': 'Input value' });
73
+ imp.addEventListener('input', function () { L.implicit = imp.value; });
74
+ var right = el('div', { style: 'flex:1;min-width:300px' },
75
+ el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Input value (what the identity profile mapping passes in)' }), imp),
76
+ el('div', { className: 'lbl', text: 'Identity attributes (JSON)' }), labCode(L.identity, 'Identity attributes JSON', 4, function (v) { L.identity = v; }),
77
+ el('div', { className: 'lbl', style: 'margin-top:10px', text: 'Accounts (JSON list; used by accountAttribute)' }), labCode(L.accounts, 'Accounts JSON', 7, function (v) { L.accounts = v; }),
78
+ el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'Each account: "source" (the source name the transform asks for), "attributes" (the account\'s attributes); optional "nativeIdentity", "name" and "created", which accountFilter and the oldest-first rule use.' }),
79
+ el('div', { className: 'lbl', style: 'margin-top:10px', text: 'Other transforms (JSON list; used by reference)' }), labCode(L.drafts, 'Other transforms JSON', 4, function (v) { L.drafts = v; }),
80
+ el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'Drafts with a "name", "type" and "attributes". A reference looks here first, then in your tenant\'s saved transforms, so you can test a chain before saving any of it.' }),
81
+ el('div', { className: 'bar', style: 'margin-top:10px' }, runBtn));
82
+ w.appendChild(el('div', { style: 'display:flex;gap:16px;flex-wrap:wrap;margin-bottom:14px' }, left, right));
83
+
84
+ if (L.error) w.appendChild(el('div', { className: 'error', text: L.error }));
85
+ var R = L.result;
86
+ if (R) {
87
+ var r = R.result;
88
+ w.appendChild(section('Result', null, el('div', {},
89
+ el('div', { className: 'bar', style: 'margin-bottom:10px' }, el('b', { text: 'Value: ' }), labValue(r.value), labStatus(r.status)),
90
+ r.error ? el('div', { className: 'error', text: r.error }) : null,
91
+ r.assumptions.length ? el('div', { className: 'note' }, el('b', { text: 'Assumed where SailPoint does not document it: ' }), r.assumptions.join(' · ')) : null,
92
+ simpleTable(['Step', 'Transform', 'Input', 'Output', 'Note'], r.trace.map(function (s) {
93
+ return [el('span', { style: 'padding-left:' + (s.depth * 14) + 'px', text: s.type }), s.name || null, s.input === undefined ? null : labValue(s.input), s.error ? pill(s.error, 'lose') : labValue(s.output), s.note || null];
94
+ }), 'How the value was worked out'))));
95
+ }
96
+ renderLabCases(w, L, rr);
97
+ renderLabPeople(w, L, rr);
98
+ }
99
+ function labInput(L, implicit) {
100
+ var input = { implicit: implicit === undefined ? (L.implicit === '' ? undefined : L.implicit) : implicit };
101
+ var id = labParse(L.identity, 'Identity attributes'); if (id) input.identity = id;
102
+ var ac = labParse(L.accounts, 'Accounts'); if (ac) input.accounts = ac;
103
+ return input;
104
+ }
105
+ function labRunTransform(L, rr) {
106
+ L.error = null;
107
+ try {
108
+ var tr = labParse(L.json, 'The transform');
109
+ var cases = L.cases.map(function (c) { return { name: c.name, expected: c.expected, input: labInput(L, c.implicit) }; });
110
+ api('/api/lab/transform/run', 'POST', { transform: tr, input: labInput(L), cases: cases, transforms: labParse(L.drafts, 'Other transforms') }).then(function (r) {
111
+ L.result = r;
112
+ (r.cases || []).forEach(function (x, i) { if (L.cases[i]) L.cases[i].last = x; });
113
+ }, function (e) { L.error = errorText(e); }).then(rr);
114
+ } catch (e) { L.error = e.message; rr(); }
115
+ }
116
+ function renderLabCases(w, L, rr) {
117
+ var addBtn = el('button', { className: 'btn sm', onclick: function () {
118
+ var got = L.result && L.result.result.value;
119
+ L.cases.push({ name: 'Case ' + (L.cases.length + 1), implicit: L.implicit, expected: got === null || got === undefined ? '' : String(got) });
120
+ rr();
121
+ } }, icon('plus'), 'Add the current input as a case');
122
+ var saveBtn = el('button', { className: 'btn sm', disabled: !L.name, onclick: function () {
123
+ api('/api/lab/tests', 'POST', { transform: L.name, cases: L.cases.map(function (c) { return { name: c.name, implicit: c.implicit, expected: c.expected }; }) }).then(function (r) { L.saved = r; toast('Test cases saved on this computer'); }, function (e) { toast(errorText(e)); });
124
+ } }, icon('save'), 'Save cases');
125
+ var passed = L.cases.filter(function (c) { return c.last && c.last.pass; }).length, ran = L.cases.filter(function (c) { return c.last; }).length;
126
+ var body = el('div', {}, el('div', { className: 'bar', style: 'margin-bottom:10px' }, addBtn, saveBtn, el('span', { className: 'muted small', text: L.name ? 'Saved for "' + L.name + '" in your IdentityScope folder.' : 'Give the transform a name to save its cases.' }), el('span', { style: 'flex:1' }), ran ? pill(passed + ' of ' + ran + ' pass', passed === ran ? 'gain' : 'lose') : null));
127
+ if (L.cases.length) {
128
+ body.appendChild(simpleTable(['Case', 'Input value', 'Expected', 'Got', ''], L.cases.map(function (c, i) {
129
+ var n = el('input', { className: 'input', value: c.name, 'aria-label': 'Case name ' + (i + 1) }); n.addEventListener('input', function () { c.name = n.value; });
130
+ var v = el('input', { className: 'input', value: c.implicit || '', 'aria-label': 'Case input ' + (i + 1) }); v.addEventListener('input', function () { c.implicit = v.value; });
131
+ var x = el('input', { className: 'input', value: c.expected || '', 'aria-label': 'Expected value ' + (i + 1) }); x.addEventListener('input', function () { c.expected = x.value; });
132
+ return [n, v, x, c.last ? el('span', {}, pill(c.last.pass ? 'pass' : 'fail', c.last.pass ? 'gain' : 'lose'), ' ', el('code', { text: c.last.got })) : null,
133
+ el('button', { className: 'btn sm', 'aria-label': 'Remove case ' + (i + 1), onclick: function () { L.cases.splice(i, 1); rr(); } }, icon('trash'))];
134
+ }), 'Test cases'));
135
+ body.appendChild(el('p', { className: 'muted small', text: 'Cases use the identity attributes and accounts above with their own input value. Run checks every case.' }));
136
+ }
137
+ w.appendChild(section('Test cases', L.cases.length, body));
138
+ }
139
+ function renderLabPeople(w, L, rr) {
140
+ var H = L.people;
141
+ var count = numSelect(L, 'count', [[50, '50 people'], [200, '200 people'], [500, '500 people'], [2000, '2,000 people']], 'How many people');
142
+ var q = attrInput(L, 'query', 'Which people (search query, optional)', 'attributes.department:Sales');
143
+ var at = attrInput(L, 'attribute', 'Compare with identity attribute (optional)', 'email');
144
+ var go = el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () {
145
+ try { runJobInto(H, '/api/lab/transform/people', { transform: labParse(L.json, 'The transform'), transforms: labParse(L.drafts, 'Other transforms'), attribute: L.attribute || undefined, query: L.query || undefined, count: L.count }, rr); } catch (e) { toast(e.message); }
146
+ } }, icon('people'), 'Run on real people');
147
+ var body = el('div', {}, el('p', { className: 'muted', text: 'Reads real people and their accounts from ISC and works the value out for each, on this computer. With an attribute to compare, it shows where the offline result differs from what ISC holds now: use it before changing a mapping, or to check this engine against your tenant.' }),
148
+ el('div', { className: 'bar', style: 'margin-bottom:12px;align-items:flex-end' }, q, at, el('label', { className: 'field', style: 'margin:0' }, el('span', { className: 'lbl', text: 'How many' }), count), go));
149
+ if (H.busy) body.appendChild(busyBox(H.busy));
150
+ if (H.error) body.appendChild(el('div', { className: 'error', text: H.error }));
151
+ if (H.data) {
152
+ var d = H.data, S = d.summary;
153
+ (d.notes || []).forEach(function (n) { body.appendChild(el('div', { className: 'note', text: n })); });
154
+ body.appendChild(el('div', { className: 'bigstats' }, d.attribute ? stat(S.same, 'same as ISC') : null, d.attribute ? stat(S.different, 'different from ISC', 'lose') : null, stat(S.empty, 'no value'), stat(S.errors, 'errors', 'lose'), stat(S.iscOnly + S.random, 'only ISC can say'), stat(d.people, 'people')));
155
+ if (d.distinct.length) body.appendChild(el('p', { className: 'muted small', text: 'Most common results: ' + d.distinct.slice(0, 8).map(function (x) { return (x.value || '(empty)') + ' × ' + x.people; }).join(', ') }));
156
+ var show = d.attribute ? d.rows.slice().sort(function (a, b) { return (a.same === false ? 0 : 1) - (b.same === false ? 0 : 1); }) : d.rows;
157
+ body.appendChild(filteredTable(H, show, ['Person', d.attribute ? 'In ISC now' : 'Current', 'Offline result', 'Result'], function (r) {
158
+ return [r.person, r.current === undefined ? null : labValue(r.current), labValue(r.result), r.status !== 'ok' ? labStatus(r.status) : d.attribute ? pill(r.same ? 'same' : 'different', r.same ? 'gain' : 'lose') : null];
159
+ }, 'Transform results per person'));
160
+ }
161
+ w.appendChild(section('Try it on real people', null, body));
162
+ }
163
+
164
+ // Tenant > Workflow lab
165
+ function renderWorkflowLab(w) {
166
+ var L = labState().w, rr = renderBuild;
167
+ labLoadTenant(L, '/api/lab/workflows', rr);
168
+ w.appendChild(el('div', { className: 'note', text: 'Walks a workflow step by step on this computer with a trigger you give it: which branch each condition takes, what each variable becomes and what each action would send. Nothing is called, so the workflow does not need to be disabled. Secrets are never shown.' }));
169
+ var pick = el('select', { className: 'input', style: 'max-width:420px', 'aria-label': 'Workflow' }, el('option', { value: '', text: L.listError ? 'Could not read workflows' : L.list ? 'Pick one of your workflows...' : 'Reading your workflows...' }));
170
+ (L.list || []).forEach(function (x) { pick.appendChild(el('option', { value: x.id, text: x.name + (x.enabled ? '' : ' (disabled)') })); });
171
+ pick.value = L.pick;
172
+ pick.addEventListener('change', function () {
173
+ L.pick = pick.value;
174
+ var x = (L.list || []).filter(function (y) { return y.id === L.pick; })[0];
175
+ if (x) L.json = JSON.stringify(x.definition || {}, null, 2);
176
+ L.help = '';
177
+ L.result = null; L.replay = {}; rr();
178
+ });
179
+ var exPick = el('select', { className: 'input', style: 'max-width:360px', 'aria-label': 'Workflow examples' }, el('option', { value: '', text: 'Or start from an example...' }));
180
+ WORKFLOW_EXAMPLES.forEach(function (x, i) { exPick.appendChild(el('option', { value: String(i), text: x.title })); });
181
+ exPick.addEventListener('change', function () {
182
+ var x = WORKFLOW_EXAMPLES[Number(exPick.value)]; if (!x) return;
183
+ L.pick = ''; L.json = JSON.stringify(x.definition, null, 2); L.trigger = JSON.stringify(TRIGGER_SAMPLES[x.trigger].input, null, 2);
184
+ L.mocks = JSON.stringify(x.mocks || {}, null, 2); L.help = x.help; L.result = null; L.replay = {};
185
+ rr();
186
+ });
187
+ var trPick = el('select', { className: 'input', style: 'max-width:280px', 'aria-label': 'Trigger input samples' }, el('option', { value: '', text: 'Trigger input sample...' }));
188
+ TRIGGER_SAMPLES.forEach(function (x, i) { trPick.appendChild(el('option', { value: String(i), text: x.title })); });
189
+ trPick.addEventListener('change', function () { var x = TRIGGER_SAMPLES[Number(trPick.value)]; if (!x) return; L.trigger = JSON.stringify(x.input, null, 2); L.result = null; rr(); });
190
+ w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:10px' }, pick, exPick, trPick));
191
+ if (L.help) w.appendChild(el('div', { className: 'note' }, el('b', { text: 'About this example: ' }), L.help));
192
+ var runBtn = el('button', { className: 'btn primary', onclick: function () {
193
+ L.error = null;
194
+ try {
195
+ api('/api/lab/workflow/simulate', 'POST', { definition: labParse(L.json, 'The definition'), trigger: labParse(L.trigger, 'The trigger') || {}, mocks: labParse(L.mocks, 'Step outputs') || {} }).then(function (r) { L.result = r; }, function (e) { L.error = errorText(e); }).then(rr);
196
+ } catch (e) { L.error = e.message; rr(); }
197
+ } }, icon('play'), 'Simulate');
198
+ w.appendChild(el('div', { style: 'display:flex;gap:16px;flex-wrap:wrap;margin-bottom:14px' },
199
+ el('div', { style: 'flex:1.2;min-width:340px' }, el('div', { className: 'lbl', text: 'Definition (JSON: "start" and "steps")' }), labCode(L.json, 'Workflow definition JSON', 16, function (v) { L.json = v; })),
200
+ el('div', { style: 'flex:1;min-width:300px' }, el('div', { className: 'lbl', text: 'Trigger input (JSON)' }), labCode(L.trigger, 'Trigger JSON', 8, function (v) { L.trigger = v; }),
201
+ el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'What the trigger passes in; steps read it as $.trigger. Pick a sample above for the shape SailPoint documents per trigger, or replay a real run to use its actual input.' }),
202
+ el('div', { className: 'lbl', style: 'margin-top:10px', text: 'Step outputs to pretend (JSON: step name → output, optional)' }), labCode(L.mocks, 'Step outputs JSON', 4, function (v) { L.mocks = v; }),
203
+ el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'For steps that would read ISC or call a system, e.g. {"Get Identity": {"attributes": {"manager": {"email": "x@acme.com"}}}}. Later steps read it as $.getIdentity (the step name in camel case).' }),
204
+ el('div', { className: 'bar', style: 'margin-top:10px' }, runBtn))));
205
+ if (L.error) w.appendChild(el('div', { className: 'error', text: L.error }));
206
+ var R = L.result;
207
+ if (R) {
208
+ var tone = R.outcome === 'success' ? 'ok' : 'bad';
209
+ w.appendChild(el('div', { className: 'banner ' + tone }, el('b', { text: 'Ends in ' + R.outcome + (R.endStep ? ' at "' + R.endStep + '"' : '') }), el('span', { text: R.path.join(' → ') })));
210
+ R.warnings.forEach(function (x) { w.appendChild(el('div', { className: 'note', text: x })); });
211
+ if (R.failure) w.appendChild(el('div', { className: 'error', text: R.failure }));
212
+ w.appendChild(section('Steps', R.steps.length, simpleTable(['Step', 'Kind', 'What happens', 'Details', 'Next'], R.steps.map(function (s) {
213
+ var details = s.resolved !== undefined ? s.resolved : s.output;
214
+ return [el('span', { style: 'padding-left:' + (s.depth * 14) + 'px', text: s.step }), s.kind + (s.mocked ? ' (' + s.mocked + ' output)' : ''), el('span', {}, s.note || '', s.warning ? el('div', {}, pill(s.warning, 'lose')) : null), details === undefined ? null : el('code', { className: 'small', style: 'white-space:pre-wrap;word-break:break-word', text: JSON.stringify(details) }), s.next || null];
215
+ }), 'Simulated steps')));
216
+ }
217
+ renderReplay(w, L, rr);
218
+ }
219
+ function renderReplay(w, L, rr) {
220
+ var H = L.replay;
221
+ if (!L.replayCount) L.replayCount = 20;
222
+ var count = numSelect(L, 'replayCount', [[10, 'Last 10 runs'], [20, 'Last 20 runs'], [50, 'Last 50 runs'], [100, 'Last 100 runs']], 'How many runs');
223
+ var go = function (draft) {
224
+ return function () {
225
+ try { runJobInto(H, '/api/lab/workflow/replay', { workflowId: L.pick, count: L.replayCount, definition: draft ? labParse(L.json, 'The definition') : undefined }, rr); } catch (e) { toast(e.message); }
226
+ };
227
+ };
228
+ var body = el('div', {}, el('p', { className: 'muted', text: 'Reads the history of real runs (ISC keeps it for 90 days) and runs each one again here. "As it ran" checks the simulator against ISC. "With my edits" uses the definition above, so you can see which real runs would now take a different path before you publish.' }),
229
+ el('div', { className: 'bar', style: 'margin-bottom:12px' }, count,
230
+ el('button', { className: 'btn primary', disabled: !L.pick || !!H.busy, onclick: go(false) }, icon('lifecycle'), 'Replay as it ran'),
231
+ el('button', { className: 'btn', disabled: !L.pick || !!H.busy, onclick: go(true) }, icon('play'), 'Replay with my edits'),
232
+ L.pick ? null : el('span', { className: 'muted small', text: 'Pick one of your workflows first.' })));
233
+ if (H.busy) body.appendChild(busyBox(H.busy));
234
+ if (H.error) body.appendChild(el('div', { className: 'error', text: H.error }));
235
+ if (H.data) {
236
+ var d = H.data;
237
+ (d.notes || []).forEach(function (n) { body.appendChild(el('div', { className: 'note', text: n })); });
238
+ body.appendChild(el('div', { className: 'bigstats' }, stat(d.same, d.draft ? 'would take the same path' : 'same path as ISC'), stat(d.total - d.same, d.draft ? 'would take a different path' : 'different from ISC', 'lose'), stat(d.total, 'runs replayed')));
239
+ body.appendChild(filteredTable(H, d.results, ['Started', 'Status in ISC', 'Path in ISC', d.draft ? 'Path with your edits' : 'Simulated path', 'Result'], function (x) {
240
+ return [x.started ? x.started.slice(0, 16).replace('T', ' ') : null, x.status || null, x.realPath.join(' → '), x.simPath.join(' → '), x.same ? pill('same', 'gain') : pill(x.noTrigger ? 'no trigger recorded' : 'different at step ' + ((x.divergence && x.divergence.index + 1) || '?'), 'lose')];
241
+ }, 'Replayed runs'));
242
+ }
243
+ w.appendChild(section('Replay real runs', null, body));
244
+ }
245
+
246
+ // Tenant > Credential map
247
+ function renderCredentialMap(w) {
248
+ var H = labState().c, rr = rerenderHost;
249
+ w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' }, el('span', { className: 'muted', style: 'flex:1;min-width:260px', text: 'Every place a client ID, user or endpoint is used in workflows and source connections: a checklist for rotating a secret or promoting to production. Secret values are never read or shown; only whether one is typed in.' }),
250
+ el('button', { className: 'btn primary', disabled: !!H.busy, onclick: function () { runJobInto(H, '/api/lab/credentials/run', {}, rr); } }, icon('search'), H.data ? 'Read again' : 'Map credentials')));
251
+ if (H.busy) { w.appendChild(busyBox(H.busy)); return; }
252
+ if (H.error) { w.appendChild(el('div', { className: 'error', text: H.error })); return; }
253
+ if (!H.data) return;
254
+ var d = H.data, T = d.totals;
255
+ (d.notes || []).forEach(function (n) { w.appendChild(el('div', { className: 'note', text: n })); });
256
+ w.appendChild(el('div', { className: 'bigstats' }, stat(T.inline, 'secrets typed into a step or source', 'lose'), stat(T.otherTenant, 'calls to another ISC tenant', T.otherTenant ? 'lose' : undefined), stat(T.thisTenantByName, 'call this tenant by its name (break when promoted)', T.thisTenantByName ? 'lose' : undefined), stat(T.parameterStorage, 'use Parameter Storage'), stat(T.workflowSteps, 'workflow steps with a connection'), stat(T.sources, 'sources with a connection')));
257
+ w.appendChild(section('By credential', d.groups.length, simpleTable(['Target', 'Client ID or user', 'Uses', 'Workflows', 'Sources', 'Secret typed in'], d.groups.map(function (g) {
258
+ return [g.target || '—', g.clientId || g.user || '—', g.uses, g.workflows, g.sources, g.inline ? pill(String(g.inline), 'lose') : 0];
259
+ }), 'Credentials grouped by target')));
260
+ w.appendChild(section('Every use', d.uses.length, filteredTable(H, d.uses, ['Where', 'Name', 'Step', 'Target', 'Client ID or user', 'Secret kept as', 'Notes'], function (u) {
261
+ return [u.where, el('span', {}, u.object, u.objectEnabled === false ? el('div', { className: 'muted small', text: 'disabled' }) : null), u.step || null, u.target || null, u.clientId || u.user || null,
262
+ u.parameterStorage ? pill('Parameter Storage', 'gain') : u.hasSecret ? pill('typed in', 'lose') : 'none', u.flags.length ? el('span', {}, u.flags.map(function (f) { return el('div', { className: 'small', text: f }); })) : null];
263
+ }, 'Credential uses')));
264
+ w.appendChild(el('p', { className: 'muted small', text: 'To rotate: change the secret in the application, then update each place listed here in ISC (or once, in Parameter Storage, for steps that use it). IdentityScope stays read-only and does not change them for you.' }));
265
+ }