forest-cli 5.24.4 → 5.25.0
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.
- package/dist/services/dumpers/agent-nodejs.d.ts.map +1 -1
- package/dist/services/dumpers/agent-nodejs.js +11 -4
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/back.hbs +1 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/back.js +154 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/component.js +154 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/data-map.css +416 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/data-map.hbs +99 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/data-map.js +243 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/demo-guide.css +278 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/demo-guide.hbs +38 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/demo-guide.js +353 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-activity.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-agent.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-ai.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-charts.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-collections.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-custom-components.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-inboxes.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-roles.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-segments.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-smart-actions.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-workflows.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-workspaces.js +124 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature.css +1109 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature.hbs +286 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/go-to.hbs +4 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/go-to.js +217 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/kyc-flow.css +580 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/kyc-flow.hbs +80 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/kyc-flow.js +49 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/run-action.hbs +3 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/run-action.js +96 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/select-first.css +131 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/select-first.hbs +4 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/select-first.js +205 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/senior-guide.hbs +39 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/senior-guide.js +189 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/style.css +372 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/template.hbs +83 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/forest-layout.json +52897 -8498
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/203696b1-e9ca-45f3-9bd3-5bc6fb4fd8c3.bpmn +161 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/2bc0c0ff-486c-44b1-ae31-3de204f7b14f.bpmn +107 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/4b37a274-117f-4c2d-96ad-21d1be4d0bc7.bpmn +159 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/56ff9484-8308-4971-9e02-3de5eea2e240.bpmn +67 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/619e3e88-4a9c-4f02-84fb-732c16f9b5bf.bpmn +43 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/76516b9e-aac0-4f7b-9794-8f86c529531b.bpmn +75 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/86b4fc1e-b10a-4906-9fd1-e601eaad83c0.bpmn +81 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/92b119e5-c908-48d1-9a0d-23173c57bd5b.bpmn +47 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/92c02240-9c8a-49e7-9993-077af3e1ddcc.bpmn +77 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/aac25aee-f626-40a8-9459-d2a933fb8446.bpmn +105 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/b269dbff-5fde-401f-a05b-76a7dac79387.bpmn +75 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/d8b208a9-fc71-4005-acb9-ba5fedd2499f.bpmn +73 -0
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/e3abab67-7bc6-4a44-9848-c7f83a55a56d.bpmn +71 -0
- package/dist/services/dumpers/templates/agent-nodejs/javascript/index.hbs +45 -4
- package/dist/services/dumpers/templates/agent-nodejs/typescript/index.hbs +45 -4
- package/oclif.manifest.json +376 -376
- package/package.json +6 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/30d581e3-294e-4790-b723-0f16509ecae0.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/52e0acb4-6064-472a-9823-cdfd7fa7a3ab.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/71f692b4-fe4f-476d-8251-fdc5af1ec51e.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/9d564d80-19d1-4ce4-bb4b-aaf41e7ef5b6.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/c8ab4b5d-20df-4d28-9160-0d4376282c90.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/d0289f67-2c9e-4c69-b1ee-ecbbace841b3.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/d07aa5ee-9a49-4916-a1b5-1f953bfe9a8e.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/e25c6237-b882-498b-9655-b16b30131b10.bpmn +0 -2
- package/dist/services/dumpers/templates/agent-nodejs/common/workflows/f01b9e61-4156-47b8-b6a1-5c90adbcd2ba.bpmn +0 -2
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/* eslint-disable import/no-unresolved -- runs inside the Forest app, which provides these */
|
|
2
|
+
/* eslint-env browser */
|
|
3
|
+
/**
|
|
4
|
+
* Demo guide: a workspace Custom component for the KYC Case desk. It follows the case picked in
|
|
5
|
+
* the desk's list (`?list=`, default List_Untreated) and walks the visitor through that demo case:
|
|
6
|
+
*
|
|
7
|
+
* - KYC-DEMO-0001: each Smart Action run by hand, up to "Approve KYC - Low risk", then a pointer to
|
|
8
|
+
* case 2;
|
|
9
|
+
* - KYC-DEMO-0002: the same steps bundled in the Retail onboarding workflow, the MEDIUM rating, the
|
|
10
|
+
* escalation to a senior, then a pointer to the senior officer's desk.
|
|
11
|
+
*
|
|
12
|
+
* A step ticks itself when the case shows it done (the agent's API chart demo_guide reads the
|
|
13
|
+
* case's history, papers, rating and status), read again every POLL_MS. The text's size follows
|
|
14
|
+
* the component's box. Generated as hub/demo-guide.{hbs,js,css}.
|
|
15
|
+
*
|
|
16
|
+
* Actions a workflow runs do not tell the workspace (only a Smart Action button does): its fields
|
|
17
|
+
* and lists keep the case as it was fetched. When the case's facts change between two reads, the
|
|
18
|
+
* guide asks Forest to refresh, as after a button: the lists of kyc_cases reload (statuses, the
|
|
19
|
+
* desk buttons' locks) and the picked case is fetched again (the fields).
|
|
20
|
+
*
|
|
21
|
+
* In case 2, the step to do carries a button that starts the workflow (`?workflow=`, default Retail
|
|
22
|
+
* onboarding) on the case, or reopens its run, as Forest's own workflow button does.
|
|
23
|
+
*/
|
|
24
|
+
import { action } from '@ember/object';
|
|
25
|
+
import { inject as service } from '@ember/service';
|
|
26
|
+
import { htmlSafe } from '@ember/template';
|
|
27
|
+
import Component from '@glimmer/component';
|
|
28
|
+
import { tracked } from '@glimmer/tracking';
|
|
29
|
+
|
|
30
|
+
const POLL_MS = 2000;
|
|
31
|
+
// Forest's grid cell, in px (WORKSPACE_GRID_CELL_WIDTH and _HEIGHT).
|
|
32
|
+
const CELL = 20;
|
|
33
|
+
// The guide's content is about this many lines of its base size tall, and this many wide.
|
|
34
|
+
const EM_TALL = 42;
|
|
35
|
+
const EM_WIDE = 34;
|
|
36
|
+
|
|
37
|
+
const SENIOR = ['MEDIUM', 'HIGH'];
|
|
38
|
+
const DEFAULT_WORKFLOW = 'Retail onboarding';
|
|
39
|
+
const START = '▶ Start Retail onboarding';
|
|
40
|
+
const REOPEN = '▶ Reopen the workflow';
|
|
41
|
+
|
|
42
|
+
const CASES = {
|
|
43
|
+
'KYC-DEMO-0001': {
|
|
44
|
+
badge: 'Case 1',
|
|
45
|
+
title: 'The happy path, one action at a time',
|
|
46
|
+
intro:
|
|
47
|
+
'Run each Smart Action yourself, in order, with the buttons on the left. Each box ticks itself as soon as the case shows the step done.',
|
|
48
|
+
steps: [
|
|
49
|
+
{
|
|
50
|
+
title: 'Take the case',
|
|
51
|
+
detail: '"Take first case" selects it: its file fills the sections on the left.',
|
|
52
|
+
done: () => true,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: 'Check documents',
|
|
56
|
+
detail: 'Section 1: every paper here and valid, the proof of address under 3 months.',
|
|
57
|
+
done: f => f.documents,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
title: 'Verify document',
|
|
61
|
+
detail: 'Section 2: Onfido reads the ID and matches the selfie to it.',
|
|
62
|
+
done: f => f.idChecked,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
title: 'Screen against sanctions lists',
|
|
66
|
+
detail: 'Section 3: nobody on a sanctions or PEP list.',
|
|
67
|
+
done: f => f.screening,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
title: 'Rate the risk',
|
|
71
|
+
detail: 'Section 4: the suggested rating is LOW. Keep it.',
|
|
72
|
+
done: f => Boolean(f.riskAfter),
|
|
73
|
+
warn: f =>
|
|
74
|
+
f.riskAfter && f.riskAfter !== 'LOW'
|
|
75
|
+
? `Rated ${f.riskAfter}: case 1 is a low risk. Run "Rate the risk" again with LOW.`
|
|
76
|
+
: null,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
title: 'Approve KYC - Low risk',
|
|
80
|
+
detail: 'Section 5: the customer becomes active, with a current account and its IBAN.',
|
|
81
|
+
done: f => f.status === 'APPROVED',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
end: f =>
|
|
85
|
+
f.status === 'APPROVED'
|
|
86
|
+
? {
|
|
87
|
+
title: 'Case 1 approved!',
|
|
88
|
+
text: 'Now let’s move on to case 2: click "Take second case" in the section above.',
|
|
89
|
+
}
|
|
90
|
+
: null,
|
|
91
|
+
},
|
|
92
|
+
'KYC-DEMO-0002': {
|
|
93
|
+
badge: 'Case 2',
|
|
94
|
+
title: 'A workflow, and an escalation',
|
|
95
|
+
intro:
|
|
96
|
+
'This time the steps come bundled in a workflow: start ▶ Retail onboarding and follow its panel. It runs the same actions in order, then decides who approves.',
|
|
97
|
+
steps: [
|
|
98
|
+
{
|
|
99
|
+
title: 'Take the case',
|
|
100
|
+
detail: '"Take second case" selects it.',
|
|
101
|
+
done: () => true,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
title: 'Start ▶ Retail onboarding',
|
|
105
|
+
detail: 'Its first steps read the file and run Check documents.',
|
|
106
|
+
done: f => f.documents,
|
|
107
|
+
button: START,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
title: 'Verify the ID',
|
|
111
|
+
detail: 'The workflow asks for Verify document: Onfido checks the ID and the selfie.',
|
|
112
|
+
done: f => f.idChecked,
|
|
113
|
+
button: REOPEN,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
title: 'Screen the applicant',
|
|
117
|
+
detail: 'Screen against sanctions lists: nobody found.',
|
|
118
|
+
done: f => f.screening,
|
|
119
|
+
button: REOPEN,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
title: 'Rate the risk: MEDIUM',
|
|
123
|
+
detail: 'More money expected in than the declared income. Keep MEDIUM.',
|
|
124
|
+
done: f => SENIOR.includes(f.riskAfter),
|
|
125
|
+
button: REOPEN,
|
|
126
|
+
warn: f =>
|
|
127
|
+
f.riskAfter === 'LOW'
|
|
128
|
+
? 'Rated LOW: case 2 is meant to be MEDIUM. Run "Rate the risk" again with MEDIUM.'
|
|
129
|
+
: null,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
title: 'Sent to a senior',
|
|
133
|
+
detail:
|
|
134
|
+
'Not low: the workflow’s last step, Send for senior sign-off, puts it in the senior officer’s queue.',
|
|
135
|
+
done: f => f.escalated,
|
|
136
|
+
button: REOPEN,
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
title: 'A senior approves it',
|
|
140
|
+
detail:
|
|
141
|
+
'On the senior officer’s desk: Start processing, then ▶ Senior review; the senior decides.',
|
|
142
|
+
done: f => f.status === 'APPROVED',
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
end: f => {
|
|
146
|
+
if (f.status === 'APPROVED') {
|
|
147
|
+
return { title: 'Approved with four eyes!', text: 'That’s the whole loop: well done.' };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (f.escalated) {
|
|
151
|
+
return {
|
|
152
|
+
title: 'It’s in the senior officer’s inbox',
|
|
153
|
+
text: 'Click "Go to the senior officer’s desk" below and pick it up there.',
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return null;
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const fieldOf = (row, name) =>
|
|
163
|
+
row?.[`forest-${name}`] ?? row?.getAttributesSerialized?.()[name] ?? row?.[name];
|
|
164
|
+
|
|
165
|
+
export default class DemoGuide extends Component {
|
|
166
|
+
@service lianaServerFetch;
|
|
167
|
+
|
|
168
|
+
@service store;
|
|
169
|
+
|
|
170
|
+
@service('feature/workflow') workflowFeature;
|
|
171
|
+
|
|
172
|
+
@service('beta-collection-list-communicator') listCommunicator;
|
|
173
|
+
|
|
174
|
+
@tracked starting = false;
|
|
175
|
+
|
|
176
|
+
@tracked workflowNote = null;
|
|
177
|
+
|
|
178
|
+
@tracked facts = null;
|
|
179
|
+
|
|
180
|
+
@tracked failed = false;
|
|
181
|
+
|
|
182
|
+
// Bumped by the timer so the selection is read again (the list may change it at any time).
|
|
183
|
+
@tracked tick = 0;
|
|
184
|
+
|
|
185
|
+
constructor(owner, args) {
|
|
186
|
+
super(owner, args);
|
|
187
|
+
this.timer = window.setInterval(() => {
|
|
188
|
+
this.tick += 1;
|
|
189
|
+
this.refresh();
|
|
190
|
+
}, POLL_MS);
|
|
191
|
+
this.refresh();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
willDestroy(...args) {
|
|
195
|
+
super.willDestroy?.(...args);
|
|
196
|
+
window.clearInterval(this.timer);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
get params() {
|
|
200
|
+
const url = this.args.component?.options?.componentUrl || '';
|
|
201
|
+
|
|
202
|
+
return new URLSearchParams(url.split('?')[1] || '');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
get selected() {
|
|
206
|
+
// eslint-disable-next-line no-unused-expressions, @typescript-eslint/no-unused-expressions -- read to follow the selection on each poll
|
|
207
|
+
this.tick;
|
|
208
|
+
const list = this.args.component?.getWorkspaceComponentFromName?.(
|
|
209
|
+
this.params.get('list') || 'List_Untreated',
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
return list?.selectedRecord || null;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
get reference() {
|
|
216
|
+
return fieldOf(this.selected, 'reference') || null;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
get guide() {
|
|
220
|
+
return CASES[this.reference] || null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
async refresh() {
|
|
224
|
+
const id = this.selected?.id;
|
|
225
|
+
|
|
226
|
+
if (!id || !this.guide) {
|
|
227
|
+
this.facts = null;
|
|
228
|
+
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
try {
|
|
233
|
+
const response = await this.lianaServerFetch.fetch(
|
|
234
|
+
`/forest/_charts/demo_guide?id=${encodeURIComponent(id)}`,
|
|
235
|
+
{},
|
|
236
|
+
);
|
|
237
|
+
if (!response.ok) throw new Error(`agent answered ${response.status}`);
|
|
238
|
+
const facts = await response.json();
|
|
239
|
+
// A late answer for a case no longer picked is dropped.
|
|
240
|
+
if (this.selected?.id !== id) return;
|
|
241
|
+
this.facts = facts;
|
|
242
|
+
const print = JSON.stringify(facts);
|
|
243
|
+
if (this.seen?.id === id && this.seen.print !== print) this.refreshWorkspace();
|
|
244
|
+
this.seen = { id, print };
|
|
245
|
+
this.failed = false;
|
|
246
|
+
} catch (error) {
|
|
247
|
+
this.failed = true;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Lists of kyc_cases reloaded, the picked case fetched again: as after a Smart Action button. */
|
|
252
|
+
refreshWorkspace() {
|
|
253
|
+
try {
|
|
254
|
+
const listOf = rows => (rows?.toArray ? rows.toArray() : Array.from(rows || []));
|
|
255
|
+
const collection = listOf(this.store.peekAll('collection')).find(c => c.name === 'kyc_cases');
|
|
256
|
+
if (!collection) return;
|
|
257
|
+
this.listCommunicator.refreshAll(collection);
|
|
258
|
+
this.listCommunicator.smartActionTriggered({ collection });
|
|
259
|
+
} catch (error) {
|
|
260
|
+
console.warn('demo-guide: the workspace could not be refreshed', error);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** The case's steps, each done or not, the first open one marked as the current one. */
|
|
265
|
+
get steps() {
|
|
266
|
+
const { guide, facts } = this;
|
|
267
|
+
if (!guide) return [];
|
|
268
|
+
const ready = facts?.found && facts.reference === this.reference;
|
|
269
|
+
const states = guide.steps.map(step => ready && Boolean(step.done(facts)));
|
|
270
|
+
const current = states.indexOf(false);
|
|
271
|
+
|
|
272
|
+
return guide.steps.map((step, i) => {
|
|
273
|
+
let state = 'todo';
|
|
274
|
+
if (states[i]) state = 'done';
|
|
275
|
+
else if (i === current) state = 'current';
|
|
276
|
+
|
|
277
|
+
return {
|
|
278
|
+
number: i + 1,
|
|
279
|
+
title: step.title,
|
|
280
|
+
detail: step.detail,
|
|
281
|
+
warn: ready && step.warn ? step.warn(facts) : null,
|
|
282
|
+
className: `dg-step dg-step--${state}`,
|
|
283
|
+
mark: states[i] ? '✓' : String(i + 1),
|
|
284
|
+
// The workflow's button, on the step to do only.
|
|
285
|
+
button: state === 'current' && step.button ? step.button : null,
|
|
286
|
+
};
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
get startLabel() {
|
|
291
|
+
return this.starting ? 'Opening the workflow…' : null;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Start the workflow on the picked case, or reopen its run, as Forest's workflow button does:
|
|
296
|
+
* the record's started runs, the one of this workflow, then the workflow service.
|
|
297
|
+
*/
|
|
298
|
+
@action
|
|
299
|
+
async startWorkflow() {
|
|
300
|
+
const record = this.selected;
|
|
301
|
+
if (!record || this.starting) return;
|
|
302
|
+
const name = this.params.get('workflow') || DEFAULT_WORKFLOW;
|
|
303
|
+
const listOf = rows => (rows?.toArray ? rows.toArray() : Array.from(rows || []));
|
|
304
|
+
const collection = listOf(this.store.peekAll('collection')).find(c => c.name === 'kyc_cases');
|
|
305
|
+
const workflow = listOf(collection?.workflows).find(w => w.name === name);
|
|
306
|
+
|
|
307
|
+
if (!workflow) {
|
|
308
|
+
this.workflowNote = `No workflow "${name}" on KYC cases: use the workflow button instead.`;
|
|
309
|
+
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
this.workflowNote = null;
|
|
314
|
+
this.starting = true;
|
|
315
|
+
|
|
316
|
+
try {
|
|
317
|
+
const runs = await this.workflowFeature.getStartedWorkflowRunsForRecord(
|
|
318
|
+
collection.id,
|
|
319
|
+
record.id,
|
|
320
|
+
);
|
|
321
|
+
const run = listOf(runs).find(r => String(r.workflowId) === String(workflow.id));
|
|
322
|
+
await this.workflowFeature.startWorkflow(workflow, record, run);
|
|
323
|
+
} catch (error) {
|
|
324
|
+
this.workflowNote = 'The workflow did not open: use the workflow button instead.';
|
|
325
|
+
console.warn('demo-guide: the workflow did not start', error);
|
|
326
|
+
} finally {
|
|
327
|
+
this.starting = false;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
get end() {
|
|
332
|
+
const { guide, facts } = this;
|
|
333
|
+
|
|
334
|
+
return guide && facts?.found ? guide.end(facts) : null;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
get empty() {
|
|
338
|
+
if (this.reference && !this.guide) {
|
|
339
|
+
return `${this.reference} is not a demo case: this guide follows KYC-DEMO-0001 and KYC-DEMO-0002.`;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return 'Click "Take first case" above to start: this guide walks you through it, step by step.';
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** The base text size, from the box: the whole guide fits its height and its width. */
|
|
346
|
+
get rootStyle() {
|
|
347
|
+
const box = this.args.component?.displaySettings;
|
|
348
|
+
if (!box?.width || !box?.height) return null;
|
|
349
|
+
const size = Math.min((box.height * CELL) / EM_TALL, (box.width * CELL) / EM_WIDE);
|
|
350
|
+
|
|
351
|
+
return htmlSafe(`font-size:${Math.round(Math.max(11, Math.min(30, size)))}px`);
|
|
352
|
+
}
|
|
353
|
+
}
|
package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-activity.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/* eslint-disable import/no-unresolved -- runs inside the Forest app, which provides these */
|
|
2
|
+
/* eslint-env browser */
|
|
3
|
+
/**
|
|
4
|
+
* A feature explainer's workspace Custom component (generated by charts/features.js
|
|
5
|
+
* once per feature, with that feature's content written in). Its only way out is the Hub, plus
|
|
6
|
+
* the buttons that open the place in the demo where the feature shows.
|
|
7
|
+
*/
|
|
8
|
+
import { action } from '@ember/object';
|
|
9
|
+
import { inject as service } from '@ember/service';
|
|
10
|
+
import Component from '@glimmer/component';
|
|
11
|
+
import { tracked } from '@glimmer/tracking';
|
|
12
|
+
|
|
13
|
+
// Written at build time (scripts/build-public.js): the feature, its facts, the Hub's workspace id.
|
|
14
|
+
const FEATURE = {"hubId":"30b652d1-5f0e-4556-8a96-4863f009eb85","workspaceId":"2ce0420b-42fd-4e69-81b6-39b1788c407c","position":12,"total":12,"key":"activity","icon":"📜","name":"Activity log & audit","promise":"Who did what, on which record, and when: every click an auditor will ask about.","hubWhere":"Any record: its Activity tab.","what":["Forest records every change: records created, edited or deleted, actions run and approved, inbox tasks taken, workflow steps done, notes left.","Each entry names the person, the record and the time. Record values are not copied into the log, only the record’s id.","Open a record’s Activity tab for its history, or the project’s activity log for the whole team, filtered by person, type and date. Admins can export it."],"facts":[],"liveText":"Run an action on a desk (say Approve KYC), then open that KYC case from the list and its Activity tab: your action is there, with your name and the time.","setup":["Nothing to set up: the log is on.","Open any record, then its Activity tab.","Filter by author, activity type or date; switch newest or oldest first.","Admins: Export, pick a date range, and the file arrives by email. Field-level diffs need the audit trail on the agent."],"docs":"https://docs.forest.app/get-started/control/audit.md","art":"activity","buttons":[{"label":"Open the Onboarding desk","workspaceId":"654efc2e-e63e-4bf5-89aa-a220fec2855b","collection":null},{"label":"Open KYC cases","workspaceId":null,"collection":"kyc_cases"}]}
|
|
15
|
+
|
|
16
|
+
const UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;
|
|
17
|
+
|
|
18
|
+
/** "records.customers" in the chart's answer, or undefined. */
|
|
19
|
+
const pick = (facts, dotted) =>
|
|
20
|
+
dotted.split('.').reduce((value, key) => (value == null ? undefined : value[key]), facts);
|
|
21
|
+
const format = value => (typeof value === 'number' ? value.toLocaleString('en-GB') : value);
|
|
22
|
+
|
|
23
|
+
export default class extends Component {
|
|
24
|
+
@service lianaServerFetch;
|
|
25
|
+
|
|
26
|
+
@service router;
|
|
27
|
+
|
|
28
|
+
@tracked liveFacts = null;
|
|
29
|
+
|
|
30
|
+
@tracked liveStatus = 'loading';
|
|
31
|
+
|
|
32
|
+
feature = FEATURE;
|
|
33
|
+
|
|
34
|
+
// One flag per illustration: the template shows the one whose flag is set.
|
|
35
|
+
art = { [FEATURE.art]: true };
|
|
36
|
+
|
|
37
|
+
steps = FEATURE.setup.map((text, i) => ({ number: i + 1, text }));
|
|
38
|
+
|
|
39
|
+
hasFacts = FEATURE.facts.length > 0;
|
|
40
|
+
|
|
41
|
+
constructor(...args) {
|
|
42
|
+
super(...args);
|
|
43
|
+
if (FEATURE.facts.some(f => f.live)) this.loadFacts();
|
|
44
|
+
else this.liveStatus = 'none';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async loadFacts() {
|
|
48
|
+
try {
|
|
49
|
+
const response = await this.lianaServerFetch.fetch('/forest/_charts/feature_facts', {});
|
|
50
|
+
if (!response.ok) throw new Error(`feature_facts: ${response.status}`);
|
|
51
|
+
this.liveFacts = await response.json();
|
|
52
|
+
this.liveStatus = 'ok';
|
|
53
|
+
} catch (error) {
|
|
54
|
+
this.liveStatus = 'failed';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Static facts as they are; live ones once the chart answers ("…" until then, "–" if not). */
|
|
59
|
+
get facts() {
|
|
60
|
+
return FEATURE.facts.map(f => {
|
|
61
|
+
if (!f.live) return { label: f.label, value: format(f.value), live: false };
|
|
62
|
+
const value = this.liveFacts ? pick(this.liveFacts, f.live) : undefined;
|
|
63
|
+
let shown = '…';
|
|
64
|
+
if (value !== undefined) shown = format(value);
|
|
65
|
+
else if (this.liveStatus === 'failed' || this.liveFacts) shown = '–';
|
|
66
|
+
|
|
67
|
+
return { label: f.label, value: shown, live: true };
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get liveNote() {
|
|
72
|
+
if (this.liveStatus === 'ok') return 'Live from this demo’s data.';
|
|
73
|
+
if (this.liveStatus === 'failed') return 'Live figures unavailable: is the agent running?';
|
|
74
|
+
if (this.liveStatus === 'loading') return 'Counting…';
|
|
75
|
+
|
|
76
|
+
return '';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The current url with the workspace id swapped: no need to know Forest's url scheme. */
|
|
80
|
+
static workspacePath(workspaceId) {
|
|
81
|
+
const path = window.location.pathname;
|
|
82
|
+
const ids = path.match(UUID) || [];
|
|
83
|
+
const current =
|
|
84
|
+
FEATURE.workspaceId && path.includes(FEATURE.workspaceId)
|
|
85
|
+
? FEATURE.workspaceId
|
|
86
|
+
: ids[ids.length - 1];
|
|
87
|
+
if (!current) return null;
|
|
88
|
+
const at = path.lastIndexOf(current);
|
|
89
|
+
|
|
90
|
+
return `${path.slice(0, at)}${workspaceId}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** A table's list, assuming /<project>/<environment>/<team>/data/<table>/index. */
|
|
94
|
+
static tablePath(collection) {
|
|
95
|
+
const [project, environment, team] = window.location.pathname.split('/').filter(Boolean);
|
|
96
|
+
|
|
97
|
+
return `/${project}/${environment}/${team}/data/${collection}/index`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Inside the app when the router knows the url, else a full page load. */
|
|
101
|
+
go(path) {
|
|
102
|
+
if (!path) return;
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
const transition = this.router.transitionTo(path);
|
|
106
|
+
transition?.catch?.(error => {
|
|
107
|
+
if (error?.name !== 'TransitionAborted') window.location.assign(path);
|
|
108
|
+
});
|
|
109
|
+
} catch (error) {
|
|
110
|
+
window.location.assign(path);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@action
|
|
115
|
+
openHub() {
|
|
116
|
+
this.go(this.constructor.workspacePath(FEATURE.hubId));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@action
|
|
120
|
+
open(button) {
|
|
121
|
+
if (button.workspaceId) this.go(this.constructor.workspacePath(button.workspaceId));
|
|
122
|
+
else if (button.collection) this.go(this.constructor.tablePath(button.collection));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/* eslint-disable import/no-unresolved -- runs inside the Forest app, which provides these */
|
|
2
|
+
/* eslint-env browser */
|
|
3
|
+
/**
|
|
4
|
+
* A feature explainer's workspace Custom component (generated by charts/features.js
|
|
5
|
+
* once per feature, with that feature's content written in). Its only way out is the Hub, plus
|
|
6
|
+
* the buttons that open the place in the demo where the feature shows.
|
|
7
|
+
*/
|
|
8
|
+
import { action } from '@ember/object';
|
|
9
|
+
import { inject as service } from '@ember/service';
|
|
10
|
+
import Component from '@glimmer/component';
|
|
11
|
+
import { tracked } from '@glimmer/tracking';
|
|
12
|
+
|
|
13
|
+
// Written at build time (scripts/build-public.js): the feature, its facts, the Hub's workspace id.
|
|
14
|
+
const FEATURE = {"hubId":"30b652d1-5f0e-4556-8a96-4863f009eb85","workspaceId":"cf02cd81-1f7f-4476-8057-45e19220ba66","position":10,"total":12,"key":"agent","icon":"🛡️","name":"The agent & data privacy","promise":"Your data never leaves your infrastructure: Forest sees the shape of your tables, not the rows.","hubWhere":"This demo’s agent runs on this Mac, on port 3310.","what":["The agent is a small Node.js server you run next to your database. It is the only thing that reads and writes your data.","Forest’s servers hold the interface: layouts, segments, workflows, permissions. They receive a description of your tables (the schema), never the records.","Your browser loads the interface from Forest, then asks the agent for the data directly. Here, everything you see in a list came from localhost."],"facts":[{"value":59,"label":"tables described to Forest (schema only)"},{"live":"records.customers","label":"customers, read from the agent"},{"live":"records.transactions","label":"transactions that stay on this machine"}],"setup":["The forest start command created this agent: its code is index.ts, its secrets in .env.","Point it at your database (Postgres, MySQL, SQL Server, Mongo…) and run it: here on localhost:3310.","In production, deploy it like any service: Docker, your cloud, behind your firewall.","Customize in code: Smart Actions, computed fields, segments, charts, all in the agent."],"docs":"https://docs.forest.app/get-started/connect/architectures/self-hosted.md","art":"agent","buttons":[{"label":"Open Customers","workspaceId":null,"collection":"customers"}]}
|
|
15
|
+
|
|
16
|
+
const UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;
|
|
17
|
+
|
|
18
|
+
/** "records.customers" in the chart's answer, or undefined. */
|
|
19
|
+
const pick = (facts, dotted) =>
|
|
20
|
+
dotted.split('.').reduce((value, key) => (value == null ? undefined : value[key]), facts);
|
|
21
|
+
const format = value => (typeof value === 'number' ? value.toLocaleString('en-GB') : value);
|
|
22
|
+
|
|
23
|
+
export default class extends Component {
|
|
24
|
+
@service lianaServerFetch;
|
|
25
|
+
|
|
26
|
+
@service router;
|
|
27
|
+
|
|
28
|
+
@tracked liveFacts = null;
|
|
29
|
+
|
|
30
|
+
@tracked liveStatus = 'loading';
|
|
31
|
+
|
|
32
|
+
feature = FEATURE;
|
|
33
|
+
|
|
34
|
+
// One flag per illustration: the template shows the one whose flag is set.
|
|
35
|
+
art = { [FEATURE.art]: true };
|
|
36
|
+
|
|
37
|
+
steps = FEATURE.setup.map((text, i) => ({ number: i + 1, text }));
|
|
38
|
+
|
|
39
|
+
hasFacts = FEATURE.facts.length > 0;
|
|
40
|
+
|
|
41
|
+
constructor(...args) {
|
|
42
|
+
super(...args);
|
|
43
|
+
if (FEATURE.facts.some(f => f.live)) this.loadFacts();
|
|
44
|
+
else this.liveStatus = 'none';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async loadFacts() {
|
|
48
|
+
try {
|
|
49
|
+
const response = await this.lianaServerFetch.fetch('/forest/_charts/feature_facts', {});
|
|
50
|
+
if (!response.ok) throw new Error(`feature_facts: ${response.status}`);
|
|
51
|
+
this.liveFacts = await response.json();
|
|
52
|
+
this.liveStatus = 'ok';
|
|
53
|
+
} catch (error) {
|
|
54
|
+
this.liveStatus = 'failed';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Static facts as they are; live ones once the chart answers ("…" until then, "–" if not). */
|
|
59
|
+
get facts() {
|
|
60
|
+
return FEATURE.facts.map(f => {
|
|
61
|
+
if (!f.live) return { label: f.label, value: format(f.value), live: false };
|
|
62
|
+
const value = this.liveFacts ? pick(this.liveFacts, f.live) : undefined;
|
|
63
|
+
let shown = '…';
|
|
64
|
+
if (value !== undefined) shown = format(value);
|
|
65
|
+
else if (this.liveStatus === 'failed' || this.liveFacts) shown = '–';
|
|
66
|
+
|
|
67
|
+
return { label: f.label, value: shown, live: true };
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get liveNote() {
|
|
72
|
+
if (this.liveStatus === 'ok') return 'Live from this demo’s data.';
|
|
73
|
+
if (this.liveStatus === 'failed') return 'Live figures unavailable: is the agent running?';
|
|
74
|
+
if (this.liveStatus === 'loading') return 'Counting…';
|
|
75
|
+
|
|
76
|
+
return '';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The current url with the workspace id swapped: no need to know Forest's url scheme. */
|
|
80
|
+
static workspacePath(workspaceId) {
|
|
81
|
+
const path = window.location.pathname;
|
|
82
|
+
const ids = path.match(UUID) || [];
|
|
83
|
+
const current =
|
|
84
|
+
FEATURE.workspaceId && path.includes(FEATURE.workspaceId)
|
|
85
|
+
? FEATURE.workspaceId
|
|
86
|
+
: ids[ids.length - 1];
|
|
87
|
+
if (!current) return null;
|
|
88
|
+
const at = path.lastIndexOf(current);
|
|
89
|
+
|
|
90
|
+
return `${path.slice(0, at)}${workspaceId}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** A table's list, assuming /<project>/<environment>/<team>/data/<table>/index. */
|
|
94
|
+
static tablePath(collection) {
|
|
95
|
+
const [project, environment, team] = window.location.pathname.split('/').filter(Boolean);
|
|
96
|
+
|
|
97
|
+
return `/${project}/${environment}/${team}/data/${collection}/index`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Inside the app when the router knows the url, else a full page load. */
|
|
101
|
+
go(path) {
|
|
102
|
+
if (!path) return;
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
const transition = this.router.transitionTo(path);
|
|
106
|
+
transition?.catch?.(error => {
|
|
107
|
+
if (error?.name !== 'TransitionAborted') window.location.assign(path);
|
|
108
|
+
});
|
|
109
|
+
} catch (error) {
|
|
110
|
+
window.location.assign(path);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@action
|
|
115
|
+
openHub() {
|
|
116
|
+
this.go(this.constructor.workspacePath(FEATURE.hubId));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@action
|
|
120
|
+
open(button) {
|
|
121
|
+
if (button.workspaceId) this.go(this.constructor.workspacePath(button.workspaceId));
|
|
122
|
+
else if (button.collection) this.go(this.constructor.tablePath(button.collection));
|
|
123
|
+
}
|
|
124
|
+
}
|