forest-cli 5.24.3 → 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.
Files changed (67) hide show
  1. package/dist/services/dumpers/agent-nodejs.d.ts.map +1 -1
  2. package/dist/services/dumpers/agent-nodejs.js +11 -4
  3. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/back.hbs +1 -0
  4. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/back.js +154 -0
  5. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/component.js +154 -0
  6. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/data-map.css +416 -0
  7. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/data-map.hbs +99 -0
  8. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/data-map.js +243 -0
  9. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/demo-guide.css +278 -0
  10. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/demo-guide.hbs +38 -0
  11. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/demo-guide.js +353 -0
  12. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-activity.js +124 -0
  13. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-agent.js +124 -0
  14. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-ai.js +124 -0
  15. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-charts.js +124 -0
  16. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-collections.js +124 -0
  17. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-custom-components.js +124 -0
  18. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-inboxes.js +124 -0
  19. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-roles.js +124 -0
  20. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-segments.js +124 -0
  21. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-smart-actions.js +124 -0
  22. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-workflows.js +124 -0
  23. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature-workspaces.js +124 -0
  24. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature.css +1109 -0
  25. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/feature.hbs +286 -0
  26. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/go-to.hbs +4 -0
  27. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/go-to.js +217 -0
  28. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/kyc-flow.css +580 -0
  29. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/kyc-flow.hbs +80 -0
  30. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/kyc-flow.js +49 -0
  31. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/run-action.hbs +3 -0
  32. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/run-action.js +96 -0
  33. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/select-first.css +131 -0
  34. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/select-first.hbs +4 -0
  35. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/select-first.js +205 -0
  36. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/senior-guide.hbs +39 -0
  37. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/senior-guide.js +189 -0
  38. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/style.css +372 -0
  39. package/dist/services/dumpers/templates/agent-nodejs/common/components/hub/template.hbs +83 -0
  40. package/dist/services/dumpers/templates/agent-nodejs/common/forest-layout.json +52897 -8498
  41. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/203696b1-e9ca-45f3-9bd3-5bc6fb4fd8c3.bpmn +161 -0
  42. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/2bc0c0ff-486c-44b1-ae31-3de204f7b14f.bpmn +107 -0
  43. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/4b37a274-117f-4c2d-96ad-21d1be4d0bc7.bpmn +159 -0
  44. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/56ff9484-8308-4971-9e02-3de5eea2e240.bpmn +67 -0
  45. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/619e3e88-4a9c-4f02-84fb-732c16f9b5bf.bpmn +43 -0
  46. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/76516b9e-aac0-4f7b-9794-8f86c529531b.bpmn +75 -0
  47. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/86b4fc1e-b10a-4906-9fd1-e601eaad83c0.bpmn +81 -0
  48. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/92b119e5-c908-48d1-9a0d-23173c57bd5b.bpmn +47 -0
  49. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/92c02240-9c8a-49e7-9993-077af3e1ddcc.bpmn +77 -0
  50. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/aac25aee-f626-40a8-9459-d2a933fb8446.bpmn +105 -0
  51. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/b269dbff-5fde-401f-a05b-76a7dac79387.bpmn +75 -0
  52. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/d8b208a9-fc71-4005-acb9-ba5fedd2499f.bpmn +73 -0
  53. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/e3abab67-7bc6-4a44-9848-c7f83a55a56d.bpmn +71 -0
  54. package/dist/services/dumpers/templates/agent-nodejs/javascript/index.hbs +45 -4
  55. package/dist/services/dumpers/templates/agent-nodejs/typescript/index.hbs +45 -4
  56. package/dist/utils/messages.js +2 -2
  57. package/oclif.manifest.json +376 -376
  58. package/package.json +6 -2
  59. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/30d581e3-294e-4790-b723-0f16509ecae0.bpmn +0 -2
  60. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/52e0acb4-6064-472a-9823-cdfd7fa7a3ab.bpmn +0 -2
  61. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/71f692b4-fe4f-476d-8251-fdc5af1ec51e.bpmn +0 -2
  62. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/9d564d80-19d1-4ce4-bb4b-aaf41e7ef5b6.bpmn +0 -2
  63. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/c8ab4b5d-20df-4d28-9160-0d4376282c90.bpmn +0 -2
  64. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/d0289f67-2c9e-4c69-b1ee-ecbbace841b3.bpmn +0 -2
  65. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/d07aa5ee-9a49-4916-a1b5-1f953bfe9a8e.bpmn +0 -2
  66. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/e25c6237-b882-498b-9655-b16b30131b10.bpmn +0 -2
  67. package/dist/services/dumpers/templates/agent-nodejs/common/workflows/f01b9e61-4156-47b8-b6a1-5c90adbcd2ba.bpmn +0 -2
@@ -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":"525f3c1f-cb4d-44f1-8242-5614d9fdbce6","position":11,"total":12,"key":"ai","icon":"✨","name":"AI in Forest","promise":"AI that decides inside your procedure, explains why, and stays inside your permissions.","hubWhere":"Alerts desk: the Fraud and takeover alert workflow decides with AI.","what":["In a workflow, a decision can be left to AI: it reads what the earlier steps gathered, picks the branch, and writes down why. The analyst sees the reason and can overrule.","AI steps can also suggest the next action or fetch the fields that matter, so the analyst clicks less.","With the MCP server, an AI assistant (Claude, Cursor…) can browse records, run actions and start workflows, as the connected user, with the same permissions and audit trail."],"facts":[{"value":22,"label":"AI decisions in the workflows"},{"value":8,"label":"of 13 workflows use AI"}],"setup":["In the workflow editor, select a Decision step and set its decision maker to AI.","Make sure the steps before it read the fields the decision needs.","MCP: add the gateway to the agent (addGateway({ mcp: true })), restart, connect your assistant to <agent url>/mcp.","Turn on the MCP trigger of each workflow an assistant may start."],"docs":"https://docs.forest.app/product/embed/mcp-server.md","art":"ai","buttons":[{"label":"Open the Alerts desk","workspaceId":"0de6234b-0b10-47fd-862b-a7f88f4c3845","collection":null},{"label":"Open the Onboarding desk","workspaceId":"654efc2e-e63e-4bf5-89aa-a220fec2855b","collection":null}]}
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":"d714bf27-ffca-429d-8b7d-86f7c56b8441","position":6,"total":12,"key":"charts","icon":"📊","name":"Charts & analytics","promise":"Live counters and graphs on your data, where the team works, with no BI project.","hubWhere":"Ops overview: a live counter per queue, across the teams.","what":["A chart is a number or a graph computed from your data when the page opens: a counter, a trend over time, a breakdown, a leaderboard, progress against a target.","Build it with clicks (a table, a count or a sum, a filter), with SQL, or in the agent’s code when you need any logic at all. The Hub’s live counts are such a chart.","Charts go on dashboards, on a record’s Analytics tab, and on desks, right above the queues they count."],"facts":[{"value":16,"label":"live counters on the Ops overview"},{"live":"queues.alerts_fraud","label":"on the “Fraud and takeover alerts” counter"},{"live":"queues.transfers_validate","label":"on the “Transfers to validate” counter"},{"live":"queues.inv_open","label":"on the “Open investigations” counter"}],"setup":["Turn on the Layout Editor, open the Dashboard tab (or a record’s Analytics tab).","Click “Add a new chart”, name it, pick the type: single value, repartition, time-based, percentage, objective, leaderboard.","Pick the table, the count or sum, the filters. Or switch to SQL, or point it at a chart coded in the agent.","On a desk: drag a Chart component into the workspace."],"docs":"https://docs.forest.app/product/manage/charts/overview.md","art":"charts","buttons":[{"label":"Open the Ops overview","workspaceId":"6edb4352-9147-4d77-8cfc-4b31ec903f72","collection":null},{"label":"Open the Payments desk","workspaceId":"35e0620c-79c2-45c3-8c6d-cac353ba9342","collection":null}]}
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":"015fe3f1-901b-46de-8cab-33d6f79025bc","position":1,"total":12,"key":"collections","icon":"🗂️","name":"Collections & record pages","promise":"Every table of your bank, browsable, with a page per customer that tells the story.","hubWhere":"Customers table: open a customer for its Customer 360.","what":["Forest reads your database and shows each table as a collection: a list you can search, filter, sort and export, without writing a screen.","Open a row and you get its record: its fields, then everything linked to it. A customer shows its accounts, cards, KYC cases and alerts one click away, and documents open as PDFs.","A record page goes further: one page designed for one kind of record, like a Customer 360 that puts identity, risk and recent activity side by side."],"facts":[{"value":53,"label":"tables in the left panel"},{"live":"records.customers","label":"customers"},{"live":"records.transactions","label":"transactions"},{"value":3,"label":"record pages (Customer 360, KYC case, Alert)"}],"setup":["Nothing to build: every table the agent sends is already a collection.","Turn on the Layout Editor (top bar), click the cog next to a table: rename it, pick its summary field, hide or reorder columns.","On a record, still in the Layout Editor: reorder fields, add tabs, choose which related data shows.","For a record page, build its Summary view: drag fields, related data and actions onto it."],"docs":"https://docs.forest.app/product/build/layout-editor.md","art":"collections","buttons":[{"label":"Open Customers","workspaceId":null,"collection":"customers"},{"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":"41af05cf-b309-4601-8c7d-6912c5719da2","position":8,"total":12,"key":"custom-components","icon":"🛠️","name":"Custom components","promise":"When the built-in blocks are not enough, drop your own HTML, code and style into a page.","hubWhere":"This Hub: the cards, the live counts and the tour button.","what":["A custom component is a workspace block you write yourself: a template, a small JavaScript component and a stylesheet, served from a URL.","It runs inside Forest with the viewer’s session, so it can read the agent (charts, records) with their rights, and use Forest’s own UI pieces.","This page is one. So is the Hub: one shared template, with each feature’s content written in when the demo is built."],"facts":[{"value":13,"label":"custom pages: the Hub and 12 explainers"},{"value":3,"label":"files each: template, component, style"}],"setup":["Write three files: a template (HTML), a small JavaScript component, a stylesheet.","Serve them from a URL the browser can reach. Here a public CDN serves them, from the demo’s npm package.","In the workspace builder, drag a Custom component and give it the three URLs.","From the code, read the agent as the viewer, with their rights: here, an API chart for the live counts."],"docs":"https://docs.forest.app/product/build/workspaces.md","art":"custom","buttons":[{"label":"Open the Hub","workspaceId":"30b652d1-5f0e-4556-8a96-4863f009eb85","collection":null}]}
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":"ae9d5300-7124-41c7-8557-49758f9cda30","position":3,"total":12,"key":"inboxes","icon":"📥","name":"Inboxes & queues","promise":"Each analyst gets the next task, in the right order, and nobody works the same case twice.","hubWhere":"Onboarding desk: Retail onboarding, Business onboarding.","what":["An inbox turns a segment into a queue. An analyst clicks “Next ticket” and gets the next case, sorted the way the team decided: oldest first, highest score first.","The task is theirs until they finish it. A cap stops anyone hoarding cases, and an idle task goes back to the queue on its own.","Some inboxes are fed by workflows instead: when a step escalates, the run waits there for a senior analyst or the MLRO to pick it up."],"facts":[{"value":17,"label":"queues built on segments"},{"value":4,"label":"escalation inboxes fed by workflows"},{"live":"queues.alerts_fraud","label":"waiting in “Fraud and takeover alerts”"},{"live":"queues.disputes_new","label":"waiting in “New disputes”"}],"setup":["Turn on the Layout Editor. In the left panel, find Inboxes and click Add New.","Pick the collection, then the segment whose rows become tasks.","In the inbox settings: the sort order, the most tasks one person may hold, the idle time before a task goes back.","Put it on a desk: drag an Inbox component into a workspace."],"docs":"https://docs.forest.app/product/manage/inbox.md","art":"inboxes","buttons":[{"label":"Open the Onboarding desk","workspaceId":"654efc2e-e63e-4bf5-89aa-a220fec2855b","collection":null},{"label":"Open the Alerts desk","workspaceId":"0de6234b-0b10-47fd-862b-a7f88f4c3845","collection":null}]}
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
+ }