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
@@ -1,148 +1,148 @@
1
- // ---------- Worked examples for the Transform lab and the Workflow lab ----------
2
- // Each transform example fills every box: the transform, the input value, identity attributes,
3
- // accounts and, for references, the other transforms it uses. Values are made up.
4
- var LAB_HR_ACCOUNT = { source: 'Workday', nativeIdentity: '100234', created: '2024-03-01T09:00:00Z', attributes: { firstName: 'José', lastName: 'García Núñez', department: 'FIN', workerType: 'Employee', startDate: '2025-01-06', email: 'jose.garcia@acme.com' } };
5
- var LAB_AD_ACCOUNTS = [
6
- { source: 'Active Directory', nativeIdentity: 'CN=adm_jgarcia,OU=Admins,DC=acme,DC=com', name: 'adm_jgarcia', created: '2024-02-01T09:00:00Z', attributes: { sAMAccountName: 'adm_jgarcia', mail: 'adm_jgarcia@acme.com' } },
7
- { source: 'Active Directory', nativeIdentity: 'CN=jgarcia,OU=Users,DC=acme,DC=com', name: 'jgarcia', created: '2024-03-02T09:00:00Z', attributes: { sAMAccountName: 'jgarcia', mail: 'jose.garcia@acme.com' } },
8
- ];
9
- var LAB_IDENTITY = { firstname: 'José', lastname: 'García Núñez', department: 'Finance', email: 'jose.garcia@acme.com' };
10
- var CLEAN_NAME = { name: 'Clean Name', type: 'lower', attributes: { input: { type: 'replace', attributes: { regex: '[^A-Za-z]', replacement: '', input: { type: 'decomposeDiacriticalMarks', attributes: {} } } } } };
11
- var TRANSFORM_EXAMPLES = [
12
- {
13
- title: 'Account attribute from one source',
14
- help: 'accountAttribute reads a value from the person\'s account on a source. Put the account in the Accounts box: "source" is the source name the transform asks for, "attributes" are the account\'s attributes.',
15
- transform: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'department' } },
16
- accounts: [LAB_HR_ACCOUNT],
17
- },
18
- {
19
- title: 'Pick one of several accounts',
20
- help: 'With more than one account on a source, ISC takes the oldest unless you filter or sort. Here accountFilter skips the admin account. Remove the filter and run again to see the admin account picked instead.',
21
- transform: { type: 'accountAttribute', attributes: { sourceName: 'Active Directory', attributeName: 'mail', accountFilter: '!(nativeIdentity.startsWith("CN=adm_"))' } },
22
- accounts: LAB_AD_ACCOUNTS,
23
- },
24
- {
25
- title: 'Use another transform (reference)',
26
- help: 'A reference runs another transform by name. IdentityScope looks for it first in Other transforms (your drafts), then in the tenant\'s saved transforms, so you can test a change to "Clean Name" before saving it. The trace shows the referenced steps indented.',
27
- transform: { type: 'reference', attributes: { id: 'Clean Name', input: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'lastName' } } } },
28
- accounts: [LAB_HR_ACCOUNT],
29
- drafts: [CLEAN_NAME],
30
- },
31
- {
32
- title: 'Chain of transforms: email from names',
33
- help: 'Builds an email from first and last name, each cleaned by the "Clean Name" transform, with the domain picked from the department by a second transform, "Email Domain". Change "Clean Name" under Other transforms and run again: every transform that uses it changes too.',
34
- transform: {
35
- type: 'static',
36
- attributes: {
37
- fn: { type: 'reference', attributes: { id: 'Clean Name', input: { type: 'identityAttribute', attributes: { name: 'firstname' } } } },
38
- ln: { type: 'reference', attributes: { id: 'Clean Name', input: { type: 'identityAttribute', attributes: { name: 'lastname' } } } },
39
- domain: { type: 'reference', attributes: { id: 'Email Domain', input: { type: 'identityAttribute', attributes: { name: 'department' } } } },
40
- value: '$fn.$ln@$domain',
41
- },
42
- },
43
- identity: LAB_IDENTITY,
44
- drafts: [CLEAN_NAME, { name: 'Email Domain', type: 'lookup', attributes: { table: { Finance: 'acme.com', Research: 'labs.acme.com', default: 'acme.com' } } }],
45
- },
46
- {
47
- title: 'Lifecycle state from HR dates',
48
- help: 'The classic joiner criteria: "active" from the start date on, "prehire" before. Change startDate in the account to a future date and run again. Dates are compared in GMT, as ISC does.',
49
- transform: {
50
- type: 'dateCompare',
51
- attributes: {
52
- firstDate: { type: 'dateFormat', attributes: { inputFormat: 'yyyy-MM-dd', outputFormat: 'ISO8601', input: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'startDate' } } } },
53
- secondDate: 'now',
54
- operator: 'LTE',
55
- positiveCondition: 'active',
56
- negativeCondition: 'prehire',
57
- },
58
- },
59
- accounts: [LAB_HR_ACCOUNT],
60
- },
61
- {
62
- title: 'Lookup table with a default',
63
- help: 'lookup turns a code into a name. The input value box is what the identity profile mapping passes in; try "RND" and then a code that is not in the table to see the default.',
64
- transform: { type: 'lookup', attributes: { table: { FIN: 'Finance', RND: 'Research', OPS: 'Operations', default: 'Unknown department' } } },
65
- implicit: 'FIN',
66
- },
67
- {
68
- title: 'Conditional on an account value',
69
- help: 'conditional compares two values with "eq" and returns one of two results. The variable $type is defined in the attributes from the HR account.',
70
- transform: { type: 'conditional', attributes: { type: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'workerType' } }, expression: '$type eq Employee', positiveCondition: 'E', negativeCondition: 'C' } },
71
- accounts: [LAB_HR_ACCOUNT],
72
- },
73
- {
74
- title: 'First value that exists',
75
- help: 'firstValid returns the first value that is not empty: here the AD mail, then the HR email, then a fixed text. Empty the Accounts box to see the fallback.',
76
- transform: { type: 'firstValid', attributes: { values: [
77
- { type: 'accountAttribute', attributes: { sourceName: 'Active Directory', attributeName: 'mail', accountFilter: '!(nativeIdentity.startsWith("CN=adm_"))' } },
78
- { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'email' } },
79
- 'no-email@acme.com',
80
- ], ignoreErrors: true } },
81
- accounts: [LAB_HR_ACCOUNT].concat(LAB_AD_ACCOUNTS),
82
- },
83
- ];
84
-
85
- // Workflow examples: a definition, a trigger input in the shape SailPoint documents for that trigger,
86
- // and outputs to pretend for steps that would call ISC or another system.
87
- var TRIGGER_SAMPLES = [
88
- { title: 'Identity Attributes Changed', input: { identity: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1313', name: 'william.wilson' }, changes: [{ attribute: 'cloudLifecycleState', oldValue: 'active', newValue: 'inactive' }, { attribute: 'department', oldValue: 'Sales', newValue: 'Marketing' }] } },
89
- { title: 'Identity Created', input: { identity: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1313', name: 'william.wilson' }, attributes: { firstname: 'William', lastname: 'Wilson', email: 'william.wilson@acme.com', department: 'Sales', cloudLifecycleState: 'prehire' } } },
90
- { title: 'Access Request Submitted', input: { accessRequestId: '2c91808b6ef1d43e016efba0ce470904', requestedFor: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1313', name: 'William Wilson' }, requestedItems: [{ id: '2c91808b6ef1d43e016efba0ce470905', name: 'Engineering Access', description: 'Access to engineering database', type: 'ACCESS_PROFILE', operation: 'Add', comment: 'Needed for the project.' }], requestedBy: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1314', name: 'Rob Robertson' } } },
91
- { title: 'Account Aggregation Completed', input: { source: { type: 'SOURCE', id: '2c9180835d191a86015d28455b4b232a', name: 'HR Source' }, status: 'Error', started: '2026-11-20T22:01:50.474Z', completed: '2026-11-20T22:02:04.090Z', errors: ['Accounts unable to be aggregated.'], warnings: ['Account Skipped'], stats: { scanned: 200, unchanged: 190, changed: 6, added: 4, removed: 3 } } },
92
- { title: 'Scheduled or external (empty)', input: {} },
93
- ];
94
- var WORKFLOW_EXAMPLES = [
95
- {
96
- title: 'Leaver: open a ticket when someone becomes inactive',
97
- help: 'The comparison reads the changed lifecycle state with a JSONPath filter. Change "newValue" in the trigger to "active" and simulate again: the workflow takes the other branch and ends without the ticket.',
98
- trigger: 0,
99
- definition: { start: 'Is Leaver', steps: {
100
- 'Is Leaver': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.trigger.changes[?(@.attribute == "cloudLifecycleState")].newValue', variableB: 'inactive', nextStep: 'Get Identity' }], defaultStep: 'End - Not a leaver' },
101
- 'Get Identity': { actionId: 'sp:get-identity', attributes: { 'id.$': '$.trigger.identity.id' }, nextStep: 'Open Ticket', type: 'action', versionNumber: 2 },
102
- 'Open Ticket': { actionId: 'sp:http', attributes: { method: 'post', url: 'https://acme.service-now.com/api/now/table/incident', authenticationType: 'OAuth', jsonRequestBody: { short_description: 'Leaver: {{$.getIdentity.attributes.displayName}}', manager: '{{$.getIdentity.attributes.manager.name}}' } }, nextStep: 'End - Ticket opened', type: 'action', versionNumber: 3 },
103
- 'End - Ticket opened': { type: 'success' },
104
- 'End - Not a leaver': { type: 'success' },
105
- } },
106
- mocks: { 'Get Identity': { id: '2c91808568c529c60168cca6f90c1313', attributes: { displayName: 'William Wilson', manager: { name: 'Rob Robertson' } } } },
107
- },
108
- {
109
- title: 'Joiner: welcome email with a built variable',
110
- help: 'Define Variable builds a value from the trigger (here the first letter of the first name and the last name). Steps that read ISC, like Get Identity, are pretended with the output in the third box: edit it to try another person.',
111
- trigger: 1,
112
- definition: { start: 'Get Identity', steps: {
113
- 'Get Identity': { actionId: 'sp:get-identity', attributes: { 'id.$': '$.trigger.identity.id' }, nextStep: 'Define Variable', type: 'action', versionNumber: 2 },
114
- 'Define Variable': { actionId: 'sp:define-variable', attributes: { id: 'sp:define-variable', variables: [{ name: 'Login', 'variableA.$': '$.trigger.attributes.firstname', transforms: [{ id: 'sp:transform:substring:string', input: { start: 0, length: 1 } }, { id: 'sp:transform:concatenate:string', input: { 'variableB.$': '$.trigger.attributes.lastname' } }, { id: 'sp:transform:lower:string', input: {} }] }] }, nextStep: 'Has Manager', type: 'Mutation' },
115
- 'Has Manager': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.getIdentity.attributes.manager.email', variableB: '', nextStep: 'End - No manager' }], defaultStep: 'Send Email' },
116
- 'Send Email': { actionId: 'sp:send-email', attributes: { 'recipientEmailList.$': '$.getIdentity.attributes.manager.email', subject: 'Welcome {{$.trigger.attributes.firstname}}', body: 'Login: {{$.defineVariable.login}}' }, nextStep: 'End', type: 'action', versionNumber: 2 },
117
- 'End': { type: 'success' },
118
- 'End - No manager': { type: 'failure' },
119
- } },
120
- mocks: { 'Get Identity': { id: '2c91808568c529c60168cca6f90c1313', attributes: { displayName: 'William Wilson', manager: { name: 'Rob Robertson', email: 'rob.robertson@acme.com' } } } },
121
- },
122
- {
123
- title: 'Loop over every changed attribute',
124
- help: 'A loop runs its own steps once per item; inside it, the item is $.loop.loopInput. The simulator runs the first five items and shows each one.',
125
- trigger: 0,
126
- definition: { start: 'For Each Change', steps: {
127
- 'For Each Change': { actionId: 'sp:loop:iterator', attributes: { 'input.$': '$.trigger.changes', start: 'Is Department', steps: {
128
- 'Is Department': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.loop.loopInput.attribute', variableB: 'department', nextStep: 'Notify' }], defaultStep: 'Skip' },
129
- 'Notify': { actionId: 'sp:send-email', attributes: { recipientEmailList: ['iam-team@acme.com'], subject: 'Department changed to {{$.loop.loopInput.newValue}}' }, nextStep: 'Done', type: 'action', versionNumber: 2 },
130
- 'Done': { type: 'success' },
131
- 'Skip': { type: 'success' },
132
- } }, nextStep: 'End', type: 'action', versionNumber: 1 },
133
- 'End': { type: 'success' },
134
- } },
135
- mocks: {},
136
- },
137
- {
138
- title: 'Alert when an aggregation fails',
139
- help: 'Uses the Account Aggregation Completed trigger. Set "status" in the trigger to "Success" and simulate again: no email.',
140
- trigger: 3,
141
- definition: { start: 'Failed?', steps: {
142
- 'Failed?': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.trigger.status', variableB: 'Error', nextStep: 'Alert' }], defaultStep: 'End' },
143
- 'Alert': { actionId: 'sp:send-email', attributes: { recipientEmailList: ['iam-team@acme.com'], subject: 'Aggregation of {{$.trigger.source.name}} failed', body: '{{$.trigger.errors}}' }, nextStep: 'End', type: 'action', versionNumber: 2 },
144
- 'End': { type: 'success' },
145
- } },
146
- mocks: {},
147
- },
148
- ];
1
+ // ---------- Worked examples for the Transform lab and the Workflow lab ----------
2
+ // Each transform example fills every box: the transform, the input value, identity attributes,
3
+ // accounts and, for references, the other transforms it uses. Values are made up.
4
+ var LAB_HR_ACCOUNT = { source: 'Workday', nativeIdentity: '100234', created: '2024-03-01T09:00:00Z', attributes: { firstName: 'José', lastName: 'García Núñez', department: 'FIN', workerType: 'Employee', startDate: '2025-01-06', email: 'jose.garcia@acme.com' } };
5
+ var LAB_AD_ACCOUNTS = [
6
+ { source: 'Active Directory', nativeIdentity: 'CN=adm_jgarcia,OU=Admins,DC=acme,DC=com', name: 'adm_jgarcia', created: '2024-02-01T09:00:00Z', attributes: { sAMAccountName: 'adm_jgarcia', mail: 'adm_jgarcia@acme.com' } },
7
+ { source: 'Active Directory', nativeIdentity: 'CN=jgarcia,OU=Users,DC=acme,DC=com', name: 'jgarcia', created: '2024-03-02T09:00:00Z', attributes: { sAMAccountName: 'jgarcia', mail: 'jose.garcia@acme.com' } },
8
+ ];
9
+ var LAB_IDENTITY = { firstname: 'José', lastname: 'García Núñez', department: 'Finance', email: 'jose.garcia@acme.com' };
10
+ var CLEAN_NAME = { name: 'Clean Name', type: 'lower', attributes: { input: { type: 'replace', attributes: { regex: '[^A-Za-z]', replacement: '', input: { type: 'decomposeDiacriticalMarks', attributes: {} } } } } };
11
+ var TRANSFORM_EXAMPLES = [
12
+ {
13
+ title: 'Account attribute from one source',
14
+ help: 'accountAttribute reads a value from the person\'s account on a source. Put the account in the Accounts box: "source" is the source name the transform asks for, "attributes" are the account\'s attributes.',
15
+ transform: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'department' } },
16
+ accounts: [LAB_HR_ACCOUNT],
17
+ },
18
+ {
19
+ title: 'Pick one of several accounts',
20
+ help: 'With more than one account on a source, ISC takes the oldest unless you filter or sort. Here accountFilter skips the admin account. Remove the filter and run again to see the admin account picked instead.',
21
+ transform: { type: 'accountAttribute', attributes: { sourceName: 'Active Directory', attributeName: 'mail', accountFilter: '!(nativeIdentity.startsWith("CN=adm_"))' } },
22
+ accounts: LAB_AD_ACCOUNTS,
23
+ },
24
+ {
25
+ title: 'Use another transform (reference)',
26
+ help: 'A reference runs another transform by name. IdentityScope looks for it first in Other transforms (your drafts), then in the tenant\'s saved transforms, so you can test a change to "Clean Name" before saving it. The trace shows the referenced steps indented.',
27
+ transform: { type: 'reference', attributes: { id: 'Clean Name', input: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'lastName' } } } },
28
+ accounts: [LAB_HR_ACCOUNT],
29
+ drafts: [CLEAN_NAME],
30
+ },
31
+ {
32
+ title: 'Chain of transforms: email from names',
33
+ help: 'Builds an email from first and last name, each cleaned by the "Clean Name" transform, with the domain picked from the department by a second transform, "Email Domain". Change "Clean Name" under Other transforms and run again: every transform that uses it changes too.',
34
+ transform: {
35
+ type: 'static',
36
+ attributes: {
37
+ fn: { type: 'reference', attributes: { id: 'Clean Name', input: { type: 'identityAttribute', attributes: { name: 'firstname' } } } },
38
+ ln: { type: 'reference', attributes: { id: 'Clean Name', input: { type: 'identityAttribute', attributes: { name: 'lastname' } } } },
39
+ domain: { type: 'reference', attributes: { id: 'Email Domain', input: { type: 'identityAttribute', attributes: { name: 'department' } } } },
40
+ value: '$fn.$ln@$domain',
41
+ },
42
+ },
43
+ identity: LAB_IDENTITY,
44
+ drafts: [CLEAN_NAME, { name: 'Email Domain', type: 'lookup', attributes: { table: { Finance: 'acme.com', Research: 'labs.acme.com', default: 'acme.com' } } }],
45
+ },
46
+ {
47
+ title: 'Lifecycle state from HR dates',
48
+ help: 'The classic joiner criteria: "active" from the start date on, "prehire" before. Change startDate in the account to a future date and run again. Dates are compared in GMT, as ISC does.',
49
+ transform: {
50
+ type: 'dateCompare',
51
+ attributes: {
52
+ firstDate: { type: 'dateFormat', attributes: { inputFormat: 'yyyy-MM-dd', outputFormat: 'ISO8601', input: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'startDate' } } } },
53
+ secondDate: 'now',
54
+ operator: 'LTE',
55
+ positiveCondition: 'active',
56
+ negativeCondition: 'prehire',
57
+ },
58
+ },
59
+ accounts: [LAB_HR_ACCOUNT],
60
+ },
61
+ {
62
+ title: 'Lookup table with a default',
63
+ help: 'lookup turns a code into a name. The input value box is what the identity profile mapping passes in; try "RND" and then a code that is not in the table to see the default.',
64
+ transform: { type: 'lookup', attributes: { table: { FIN: 'Finance', RND: 'Research', OPS: 'Operations', default: 'Unknown department' } } },
65
+ implicit: 'FIN',
66
+ },
67
+ {
68
+ title: 'Conditional on an account value',
69
+ help: 'conditional compares two values with "eq" and returns one of two results. The variable $type is defined in the attributes from the HR account.',
70
+ transform: { type: 'conditional', attributes: { type: { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'workerType' } }, expression: '$type eq Employee', positiveCondition: 'E', negativeCondition: 'C' } },
71
+ accounts: [LAB_HR_ACCOUNT],
72
+ },
73
+ {
74
+ title: 'First value that exists',
75
+ help: 'firstValid returns the first value that is not empty: here the AD mail, then the HR email, then a fixed text. Empty the Accounts box to see the fallback.',
76
+ transform: { type: 'firstValid', attributes: { values: [
77
+ { type: 'accountAttribute', attributes: { sourceName: 'Active Directory', attributeName: 'mail', accountFilter: '!(nativeIdentity.startsWith("CN=adm_"))' } },
78
+ { type: 'accountAttribute', attributes: { sourceName: 'Workday', attributeName: 'email' } },
79
+ 'no-email@acme.com',
80
+ ], ignoreErrors: true } },
81
+ accounts: [LAB_HR_ACCOUNT].concat(LAB_AD_ACCOUNTS),
82
+ },
83
+ ];
84
+
85
+ // Workflow examples: a definition, a trigger input in the shape SailPoint documents for that trigger,
86
+ // and outputs to pretend for steps that would call ISC or another system.
87
+ var TRIGGER_SAMPLES = [
88
+ { title: 'Identity Attributes Changed', input: { identity: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1313', name: 'william.wilson' }, changes: [{ attribute: 'cloudLifecycleState', oldValue: 'active', newValue: 'inactive' }, { attribute: 'department', oldValue: 'Sales', newValue: 'Marketing' }] } },
89
+ { title: 'Identity Created', input: { identity: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1313', name: 'william.wilson' }, attributes: { firstname: 'William', lastname: 'Wilson', email: 'william.wilson@acme.com', department: 'Sales', cloudLifecycleState: 'prehire' } } },
90
+ { title: 'Access Request Submitted', input: { accessRequestId: '2c91808b6ef1d43e016efba0ce470904', requestedFor: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1313', name: 'William Wilson' }, requestedItems: [{ id: '2c91808b6ef1d43e016efba0ce470905', name: 'Engineering Access', description: 'Access to engineering database', type: 'ACCESS_PROFILE', operation: 'Add', comment: 'Needed for the project.' }], requestedBy: { type: 'IDENTITY', id: '2c91808568c529c60168cca6f90c1314', name: 'Rob Robertson' } } },
91
+ { title: 'Account Aggregation Completed', input: { source: { type: 'SOURCE', id: '2c9180835d191a86015d28455b4b232a', name: 'HR Source' }, status: 'Error', started: '2026-11-20T22:01:50.474Z', completed: '2026-11-20T22:02:04.090Z', errors: ['Accounts unable to be aggregated.'], warnings: ['Account Skipped'], stats: { scanned: 200, unchanged: 190, changed: 6, added: 4, removed: 3 } } },
92
+ { title: 'Scheduled or external (empty)', input: {} },
93
+ ];
94
+ var WORKFLOW_EXAMPLES = [
95
+ {
96
+ title: 'Leaver: open a ticket when someone becomes inactive',
97
+ help: 'The comparison reads the changed lifecycle state with a JSONPath filter. Change "newValue" in the trigger to "active" and simulate again: the workflow takes the other branch and ends without the ticket.',
98
+ trigger: 0,
99
+ definition: { start: 'Is Leaver', steps: {
100
+ 'Is Leaver': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.trigger.changes[?(@.attribute == "cloudLifecycleState")].newValue', variableB: 'inactive', nextStep: 'Get Identity' }], defaultStep: 'End - Not a leaver' },
101
+ 'Get Identity': { actionId: 'sp:get-identity', attributes: { 'id.$': '$.trigger.identity.id' }, nextStep: 'Open Ticket', type: 'action', versionNumber: 2 },
102
+ 'Open Ticket': { actionId: 'sp:http', attributes: { method: 'post', url: 'https://acme.service-now.com/api/now/table/incident', authenticationType: 'OAuth', jsonRequestBody: { short_description: 'Leaver: {{$.getIdentity.attributes.displayName}}', manager: '{{$.getIdentity.attributes.manager.name}}' } }, nextStep: 'End - Ticket opened', type: 'action', versionNumber: 3 },
103
+ 'End - Ticket opened': { type: 'success' },
104
+ 'End - Not a leaver': { type: 'success' },
105
+ } },
106
+ mocks: { 'Get Identity': { id: '2c91808568c529c60168cca6f90c1313', attributes: { displayName: 'William Wilson', manager: { name: 'Rob Robertson' } } } },
107
+ },
108
+ {
109
+ title: 'Joiner: welcome email with a built variable',
110
+ help: 'Define Variable builds a value from the trigger (here the first letter of the first name and the last name). Steps that read ISC, like Get Identity, are pretended with the output in the third box: edit it to try another person.',
111
+ trigger: 1,
112
+ definition: { start: 'Get Identity', steps: {
113
+ 'Get Identity': { actionId: 'sp:get-identity', attributes: { 'id.$': '$.trigger.identity.id' }, nextStep: 'Define Variable', type: 'action', versionNumber: 2 },
114
+ 'Define Variable': { actionId: 'sp:define-variable', attributes: { id: 'sp:define-variable', variables: [{ name: 'Login', 'variableA.$': '$.trigger.attributes.firstname', transforms: [{ id: 'sp:transform:substring:string', input: { start: 0, length: 1 } }, { id: 'sp:transform:concatenate:string', input: { 'variableB.$': '$.trigger.attributes.lastname' } }, { id: 'sp:transform:lower:string', input: {} }] }] }, nextStep: 'Has Manager', type: 'Mutation' },
115
+ 'Has Manager': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.getIdentity.attributes.manager.email', variableB: '', nextStep: 'End - No manager' }], defaultStep: 'Send Email' },
116
+ 'Send Email': { actionId: 'sp:send-email', attributes: { 'recipientEmailList.$': '$.getIdentity.attributes.manager.email', subject: 'Welcome {{$.trigger.attributes.firstname}}', body: 'Login: {{$.defineVariable.login}}' }, nextStep: 'End', type: 'action', versionNumber: 2 },
117
+ 'End': { type: 'success' },
118
+ 'End - No manager': { type: 'failure' },
119
+ } },
120
+ mocks: { 'Get Identity': { id: '2c91808568c529c60168cca6f90c1313', attributes: { displayName: 'William Wilson', manager: { name: 'Rob Robertson', email: 'rob.robertson@acme.com' } } } },
121
+ },
122
+ {
123
+ title: 'Loop over every changed attribute',
124
+ help: 'A loop runs its own steps once per item; inside it, the item is $.loop.loopInput. The simulator runs the first five items and shows each one.',
125
+ trigger: 0,
126
+ definition: { start: 'For Each Change', steps: {
127
+ 'For Each Change': { actionId: 'sp:loop:iterator', attributes: { 'input.$': '$.trigger.changes', start: 'Is Department', steps: {
128
+ 'Is Department': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.loop.loopInput.attribute', variableB: 'department', nextStep: 'Notify' }], defaultStep: 'Skip' },
129
+ 'Notify': { actionId: 'sp:send-email', attributes: { recipientEmailList: ['iam-team@acme.com'], subject: 'Department changed to {{$.loop.loopInput.newValue}}' }, nextStep: 'Done', type: 'action', versionNumber: 2 },
130
+ 'Done': { type: 'success' },
131
+ 'Skip': { type: 'success' },
132
+ } }, nextStep: 'End', type: 'action', versionNumber: 1 },
133
+ 'End': { type: 'success' },
134
+ } },
135
+ mocks: {},
136
+ },
137
+ {
138
+ title: 'Alert when an aggregation fails',
139
+ help: 'Uses the Account Aggregation Completed trigger. Set "status" in the trigger to "Success" and simulate again: no email.',
140
+ trigger: 3,
141
+ definition: { start: 'Failed?', steps: {
142
+ 'Failed?': { type: 'choice', choiceList: [{ comparator: 'StringEquals', 'variableA.$': '$.trigger.status', variableB: 'Error', nextStep: 'Alert' }], defaultStep: 'End' },
143
+ 'Alert': { actionId: 'sp:send-email', attributes: { recipientEmailList: ['iam-team@acme.com'], subject: 'Aggregation of {{$.trigger.source.name}} failed', body: '{{$.trigger.errors}}' }, nextStep: 'End', type: 'action', versionNumber: 2 },
144
+ 'End': { type: 'success' },
145
+ } },
146
+ mocks: {},
147
+ },
148
+ ];
@@ -1,89 +1,89 @@
1
- // ---------- Quick finder: every page, tab and report in one search (Ctrl+K) ----------
2
- // Each entry: [label, where it is, extra words people search for, how to go there].
3
- function finderEntries() {
4
- var go = function (page, set) { return function () { if (set) set(); showPage(page); }; };
5
- var tab = function (obj, key, id) { return function () { obj()[key] = id; }; };
6
- var list = [
7
- ['Reports', 'All reports, by category', 'library run schedule export', go('reports')],
8
- ['Instant check', 'Health tiles for the whole tenant', 'dashboard tiles health status overview', go('checks')],
9
- ['Schedules', 'Reports sent by email or chat on a schedule', 'email teams slack webhook daily weekly', go('schedules')],
10
- ];
11
- var add = function (page, pageLabel, holder, key, tabs) {
12
- tabs.forEach(function (t) { list.push([t[1], pageLabel + ' > ' + t[1], (t[2] || '') + ' ' + pageLabel, go(page, tab(holder, key, t[0]))]); });
13
- };
14
- add('warnings', 'Warnings', wnState, 'tab', WN_TABS.map(function (t) { return [t[0], t[1], t[3]]; }));
15
- add('lookup', 'Lookup', function () { return state.lk; }, 'tab', [['person', 'Person', 'user identity everything one person has accounts access requests events'], ['source', 'Source', 'application connector errors aggregation'], ['ownership', 'Ownership', 'owners owner left without owner']]);
16
- add('tenant', 'Tenant', function () { return state.tn; }, 'tab', [
17
- ['overview', 'Overview', 'counts sources identities size'], ['clusters', 'Virtual Appliances', 'va cluster health'],
18
- ['workflows', 'Workflows', 'workflow health runs failures failed causes errors trends'], ['transforms', 'Transforms', 'transform impact where used unused references provisioning policies'],
19
- ['credentials', 'API credentials', 'pat personal access token oauth client expiry expiring'], ['cmap', 'Credential map', 'client id secret rotate promote parameter storage servicenow http'],
20
- ['compare', 'Compare tenants', 'sandbox production diff rules cloud rules connector rules promote'], ['rules', 'Rule usage', 'unused rules cleanup connector rule cloud rule where used missing']]);
21
- add('logs', 'Logs', lgState, 'tab', LG_TABS.map(function (t) { return [t[0], t[1], t[3] + ' log ccg virtual appliance va connector error aggregation']; }));
22
- add('nerm', 'Non-employees', nmState, 'tab', NM_TABS.map(function (t) { return [t[0], t[1], t[3] + ' nerm contractor vendor sponsor non-employee risk management']; }));
23
- add('build', 'Build & test', function () { return state.bt; }, 'tab', BUILD_TABS.map(function (t) {
24
- return [t[0], t[1], { tlab: 'transform test velocity offline try draft reference account attribute', policy: 'provisioning policy create account preview joiner fields', wlab: 'workflow simulate trigger replay test without disabling' }[t[0]]];
25
- }));
26
- add('certs', 'Audit', function () { return state.au; }, 'tab', [
27
- ['certs', 'Certifications', 'campaigns reviewers progress rubber stamp'], ['outmodel', 'Outside roles', 'entitlements not assigned via roles direct access standalone birthright outside the model'], ['composition', 'What is in every role', 'role composition entitlements by role access profiles breakdown export'], ['reassigned', 'Reassigned reviews', 'certification reassignment forwarded delegated reviewer'], ['sod', 'Separation of duties', 'sod toxic conflicts rules'],
28
- ['coverage', 'Review coverage', 'certified access never reviewed'], ['outliers', 'Access outliers', 'peer unusual compared with peers'],
29
- ['speed', 'Provisioning speed', 'slow removals how long'], ['adminaccts', 'Admin accounts', 'privileged admin service test accounts linked'],
30
- ['exceptions', 'Exceptions', 'accepted risk exception register'], ['trail', 'Request trail', 'access request approvals approver comment decision audit history who approved'], ['chain', 'Approver chain', 'approval schemes who approves governance group revoke approval'], ['leavertimes', 'Leaver removal times', 'termination leaver sla disabled how long per person'], ['attrhist', 'Attribute changes', 'manager change department title history who changed'], ['owners', 'Entitlement owners', 'owner review holders who has my entitlement'], ['changes', 'Change history', 'snapshot drift baseline approved release what changed'],
31
- ['evidence', 'Evidence pack', 'auditor zip excel evidence']]);
32
- add('roles', 'Role tools', function () { return state; }, 'roleTab', [['compare', 'Compare roles', 'role differences'], ['impact', 'Preview a role change', 'criteria membership who gains loses simulate'], ['mining', 'Find candidate roles', 'role mining common access']]);
33
- add('monthly', 'Insights', function () { return state.inz; }, 'tab', [['monthly', 'Monthly report', 'management summary trend'], ['reclaim', 'License reclaim', 'cost dormant licenses save money'], ['requests', 'Access requests', 'approvers requested reject rate']]);
34
- (state.reports || []).forEach(function (r) {
35
- var d = r.definition || r;
36
- if (!d || !d.name) return;
37
- list.push([d.name, 'Report · ' + (d.category || ''), (d.description || '') + ' ' + (d.tags || []).join(' '), function () { showPage('reports'); loadLibrary(d.id); }]);
38
- });
39
- return list;
40
- }
41
- function finderScore(e, words) {
42
- var name = String(e[0]).toLowerCase(), hay = (e[0] + ' ' + e[1] + ' ' + (e[2] || '')).toLowerCase(), score = 0;
43
- for (var i = 0; i < words.length; i++) {
44
- var w = words[i];
45
- if (hay.indexOf(w) < 0) return -1;
46
- score += name.indexOf(w) === 0 ? 6 : name.indexOf(w) >= 0 ? 4 : String(e[1]).toLowerCase().indexOf(w) >= 0 ? 2 : 1;
47
- }
48
- return score;
49
- }
50
- function openFinder() {
51
- if ($('btn-help').classList.contains('hidden') || document.querySelector('.finder')) return;
52
- var entries = finderEntries(), sel = 0, shown = [];
53
- var before = document.activeElement;
54
- var input = el('input', { className: 'input', placeholder: 'Find a page, tab or report...', 'aria-label': 'Find a page, tab or report', role: 'combobox', 'aria-expanded': 'true', 'aria-controls': 'finder-list', autocomplete: 'off' });
55
- var listBox = el('ul', { id: 'finder-list', role: 'listbox', className: 'finder-list', 'aria-label': 'Matches' });
56
- var back = el('div', { className: 'finder-back' });
57
- var box = el('div', { className: 'finder', role: 'dialog', 'aria-modal': 'true', 'aria-label': 'Find' }, input, listBox,
58
- el('div', { className: 'muted small', style: 'padding:8px 12px', text: '↑ ↓ to move, Enter to open, Esc to close' }));
59
- back.appendChild(box);
60
- var close = function () { back.remove(); if (before && before.focus) before.focus(); };
61
- var pick = function (e) { close(); e[3](); };
62
- var draw = function () {
63
- var words = input.value.toLowerCase().split(/\s+/).filter(Boolean);
64
- shown = words.length ? entries.map(function (e) { return [finderScore(e, words), e]; }).filter(function (x) { return x[0] >= 0; }).sort(function (a, b) { return b[0] - a[0] || String(a[1][0]).length - String(b[1][0]).length; }).slice(0, 12).map(function (x) { return x[1]; }) : entries.slice(0, 12);
65
- sel = Math.min(sel, Math.max(0, shown.length - 1));
66
- listBox.textContent = '';
67
- shown.forEach(function (e, i) {
68
- var li = el('li', { id: 'finder-opt-' + i, role: 'option', className: 'finder-opt' + (i === sel ? ' active' : ''), 'aria-selected': i === sel ? 'true' : 'false' }, el('b', { text: e[0] }), el('span', { className: 'muted small', text: e[1] }));
69
- li.addEventListener('mousedown', function (ev) { ev.preventDefault(); pick(e); });
70
- listBox.appendChild(li);
71
- });
72
- if (!shown.length) listBox.appendChild(el('li', { className: 'muted', style: 'padding:10px 12px', text: 'Nothing matches.' }));
73
- input.setAttribute('aria-activedescendant', shown.length ? 'finder-opt-' + sel : '');
74
- };
75
- input.addEventListener('input', function () { sel = 0; draw(); });
76
- input.addEventListener('keydown', function (ev) {
77
- if (ev.key === 'ArrowDown') { sel = Math.min(sel + 1, shown.length - 1); draw(); ev.preventDefault(); }
78
- else if (ev.key === 'ArrowUp') { sel = Math.max(sel - 1, 0); draw(); ev.preventDefault(); }
79
- else if (ev.key === 'Enter' && shown[sel]) { pick(shown[sel]); ev.preventDefault(); }
80
- else if (ev.key === 'Escape') { close(); ev.preventDefault(); }
81
- });
82
- back.addEventListener('mousedown', function (ev) { if (ev.target === back) close(); });
83
- document.body.appendChild(back);
84
- draw();
85
- input.focus();
86
- }
87
- document.addEventListener('keydown', function (ev) {
88
- if ((ev.ctrlKey || ev.metaKey) && !ev.altKey && (ev.key === 'k' || ev.key === 'K')) { ev.preventDefault(); openFinder(); }
89
- });
1
+ // ---------- Quick finder: every page, tab and report in one search (Ctrl+K) ----------
2
+ // Each entry: [label, where it is, extra words people search for, how to go there].
3
+ function finderEntries() {
4
+ var go = function (page, set) { return function () { if (set) set(); showPage(page); }; };
5
+ var tab = function (obj, key, id) { return function () { obj()[key] = id; }; };
6
+ var list = [
7
+ ['Reports', 'All reports, by category', 'library run schedule export', go('reports')],
8
+ ['Instant check', 'Health tiles for the whole tenant', 'dashboard tiles health status overview', go('checks')],
9
+ ['Schedules', 'Reports sent by email or chat on a schedule', 'email teams slack webhook daily weekly', go('schedules')],
10
+ ];
11
+ var add = function (page, pageLabel, holder, key, tabs) {
12
+ tabs.forEach(function (t) { list.push([t[1], pageLabel + ' > ' + t[1], (t[2] || '') + ' ' + pageLabel, go(page, tab(holder, key, t[0]))]); });
13
+ };
14
+ add('warnings', 'Warnings', wnState, 'tab', WN_TABS.map(function (t) { return [t[0], t[1], t[3]]; }));
15
+ add('lookup', 'Lookup', function () { return state.lk; }, 'tab', [['person', 'Person', 'user identity everything one person has accounts access requests events'], ['source', 'Source', 'application connector errors aggregation'], ['ownership', 'Ownership', 'owners owner left without owner']]);
16
+ add('tenant', 'Tenant', function () { return state.tn; }, 'tab', [
17
+ ['overview', 'Overview', 'counts sources identities size'], ['clusters', 'Virtual Appliances', 'va cluster health'],
18
+ ['workflows', 'Workflows', 'workflow health runs failures failed causes errors trends'], ['transforms', 'Transforms', 'transform impact where used unused references provisioning policies'],
19
+ ['credentials', 'API credentials', 'pat personal access token oauth client expiry expiring'], ['cmap', 'Credential map', 'client id secret rotate promote parameter storage servicenow http'],
20
+ ['compare', 'Compare tenants', 'sandbox production diff rules cloud rules connector rules promote'], ['rules', 'Rule usage', 'unused rules cleanup connector rule cloud rule where used missing']]);
21
+ add('logs', 'Logs', lgState, 'tab', LG_TABS.map(function (t) { return [t[0], t[1], t[3] + ' log ccg virtual appliance va connector error aggregation']; }));
22
+ add('nerm', 'Non-employees', nmState, 'tab', NM_TABS.map(function (t) { return [t[0], t[1], t[3] + ' nerm contractor vendor sponsor non-employee risk management']; }));
23
+ add('build', 'Build & test', function () { return state.bt; }, 'tab', BUILD_TABS.map(function (t) {
24
+ return [t[0], t[1], { tlab: 'transform test velocity offline try draft reference account attribute', policy: 'provisioning policy create account preview joiner fields', wlab: 'workflow simulate trigger replay test without disabling' }[t[0]]];
25
+ }));
26
+ add('certs', 'Audit', function () { return state.au; }, 'tab', [
27
+ ['certs', 'Certifications', 'campaigns reviewers progress rubber stamp'], ['outmodel', 'Outside roles', 'entitlements not assigned via roles direct access standalone birthright outside the model'], ['composition', 'What is in every role', 'role composition entitlements by role access profiles breakdown export'], ['reassigned', 'Reassigned reviews', 'certification reassignment forwarded delegated reviewer'], ['sod', 'Separation of duties', 'sod toxic conflicts rules'],
28
+ ['coverage', 'Review coverage', 'certified access never reviewed'], ['outliers', 'Access outliers', 'peer unusual compared with peers'],
29
+ ['speed', 'Provisioning speed', 'slow removals how long'], ['adminaccts', 'Admin accounts', 'privileged admin service test accounts linked'],
30
+ ['exceptions', 'Exceptions', 'accepted risk exception register'], ['trail', 'Request trail', 'access request approvals approver comment decision audit history who approved'], ['chain', 'Approver chain', 'approval schemes who approves governance group revoke approval'], ['leavertimes', 'Leaver removal times', 'termination leaver sla disabled how long per person'], ['attrhist', 'Attribute changes', 'manager change department title history who changed'], ['owners', 'Entitlement owners', 'owner review holders who has my entitlement'], ['changes', 'Change history', 'snapshot drift baseline approved release what changed'],
31
+ ['evidence', 'Evidence pack', 'auditor zip excel evidence']]);
32
+ add('roles', 'Role tools', function () { return state; }, 'roleTab', [['compare', 'Compare roles', 'role differences'], ['impact', 'Preview a role change', 'criteria membership who gains loses simulate'], ['mining', 'Find candidate roles', 'role mining common access']]);
33
+ add('monthly', 'Insights', function () { return state.inz; }, 'tab', [['monthly', 'Monthly report', 'management summary trend'], ['reclaim', 'License reclaim', 'cost dormant licenses save money'], ['requests', 'Access requests', 'approvers requested reject rate']]);
34
+ (state.reports || []).forEach(function (r) {
35
+ var d = r.definition || r;
36
+ if (!d || !d.name) return;
37
+ list.push([d.name, 'Report · ' + (d.category || ''), (d.description || '') + ' ' + (d.tags || []).join(' '), function () { showPage('reports'); loadLibrary(d.id); }]);
38
+ });
39
+ return list;
40
+ }
41
+ function finderScore(e, words) {
42
+ var name = String(e[0]).toLowerCase(), hay = (e[0] + ' ' + e[1] + ' ' + (e[2] || '')).toLowerCase(), score = 0;
43
+ for (var i = 0; i < words.length; i++) {
44
+ var w = words[i];
45
+ if (hay.indexOf(w) < 0) return -1;
46
+ score += name.indexOf(w) === 0 ? 6 : name.indexOf(w) >= 0 ? 4 : String(e[1]).toLowerCase().indexOf(w) >= 0 ? 2 : 1;
47
+ }
48
+ return score;
49
+ }
50
+ function openFinder() {
51
+ if ($('btn-help').classList.contains('hidden') || document.querySelector('.finder')) return;
52
+ var entries = finderEntries(), sel = 0, shown = [];
53
+ var before = document.activeElement;
54
+ var input = el('input', { className: 'input', placeholder: 'Find a page, tab or report...', 'aria-label': 'Find a page, tab or report', role: 'combobox', 'aria-expanded': 'true', 'aria-controls': 'finder-list', autocomplete: 'off' });
55
+ var listBox = el('ul', { id: 'finder-list', role: 'listbox', className: 'finder-list', 'aria-label': 'Matches' });
56
+ var back = el('div', { className: 'finder-back' });
57
+ var box = el('div', { className: 'finder', role: 'dialog', 'aria-modal': 'true', 'aria-label': 'Find' }, input, listBox,
58
+ el('div', { className: 'muted small', style: 'padding:8px 12px', text: '↑ ↓ to move, Enter to open, Esc to close' }));
59
+ back.appendChild(box);
60
+ var close = function () { back.remove(); if (before && before.focus) before.focus(); };
61
+ var pick = function (e) { close(); e[3](); };
62
+ var draw = function () {
63
+ var words = input.value.toLowerCase().split(/\s+/).filter(Boolean);
64
+ shown = words.length ? entries.map(function (e) { return [finderScore(e, words), e]; }).filter(function (x) { return x[0] >= 0; }).sort(function (a, b) { return b[0] - a[0] || String(a[1][0]).length - String(b[1][0]).length; }).slice(0, 12).map(function (x) { return x[1]; }) : entries.slice(0, 12);
65
+ sel = Math.min(sel, Math.max(0, shown.length - 1));
66
+ listBox.textContent = '';
67
+ shown.forEach(function (e, i) {
68
+ var li = el('li', { id: 'finder-opt-' + i, role: 'option', className: 'finder-opt' + (i === sel ? ' active' : ''), 'aria-selected': i === sel ? 'true' : 'false' }, el('b', { text: e[0] }), el('span', { className: 'muted small', text: e[1] }));
69
+ li.addEventListener('mousedown', function (ev) { ev.preventDefault(); pick(e); });
70
+ listBox.appendChild(li);
71
+ });
72
+ if (!shown.length) listBox.appendChild(el('li', { className: 'muted', style: 'padding:10px 12px', text: 'Nothing matches.' }));
73
+ input.setAttribute('aria-activedescendant', shown.length ? 'finder-opt-' + sel : '');
74
+ };
75
+ input.addEventListener('input', function () { sel = 0; draw(); });
76
+ input.addEventListener('keydown', function (ev) {
77
+ if (ev.key === 'ArrowDown') { sel = Math.min(sel + 1, shown.length - 1); draw(); ev.preventDefault(); }
78
+ else if (ev.key === 'ArrowUp') { sel = Math.max(sel - 1, 0); draw(); ev.preventDefault(); }
79
+ else if (ev.key === 'Enter' && shown[sel]) { pick(shown[sel]); ev.preventDefault(); }
80
+ else if (ev.key === 'Escape') { close(); ev.preventDefault(); }
81
+ });
82
+ back.addEventListener('mousedown', function (ev) { if (ev.target === back) close(); });
83
+ document.body.appendChild(back);
84
+ draw();
85
+ input.focus();
86
+ }
87
+ document.addEventListener('keydown', function (ev) {
88
+ if ((ev.ctrlKey || ev.metaKey) && !ev.altKey && (ev.key === 'k' || ev.key === 'K')) { ev.preventDefault(); openFinder(); }
89
+ });