autosolutions-os 0.2.5 → 0.3.1
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/CHANGELOG.md +165 -0
- package/README.md +104 -55
- package/dist/federation.d.ts +143 -0
- package/dist/federation.js +408 -0
- package/dist/frame.d.ts +13 -7
- package/dist/frame.js +5 -4
- package/dist/nav.d.ts +120 -53
- package/dist/nav.js +257 -141
- package/dist/session.d.ts +19 -0
- package/dist/session.js +10 -3
- package/package.json +3 -2
package/dist/nav.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The OS menu: the rail every app shows,
|
|
3
|
-
*
|
|
4
|
-
* place in the workspace frame and a click
|
|
2
|
+
* The OS menu: the rail every app shows, Cliff's menu map by function (the
|
|
3
|
+
* design of 16 October 2026), the Hub's own panel, and the one set of routing
|
|
4
|
+
* rules that turns a location into a place in the workspace frame and a click
|
|
5
|
+
* into a destination.
|
|
5
6
|
*
|
|
6
7
|
* Three levels, the same in every AutoSolutions webapp:
|
|
7
|
-
* 1 the rail
|
|
8
|
-
* 2 the menu
|
|
9
|
-
*
|
|
8
|
+
* 1 the rail Hub, Finance, Marketing, Commercial, Operations
|
|
9
|
+
* 2 the menu that function's tools, grouped Reporting / Planning
|
|
10
|
+
* (Performance / Planning / Creative in Marketing),
|
|
11
|
+
* an Overview first in Finance, Commercial and
|
|
12
|
+
* Operations; the Hub's is Smart Comms Hub and
|
|
13
|
+
* Assistants
|
|
14
|
+
* 3 the tool's panel an app's own tool, open: its icon and name, then its
|
|
15
|
+
* views as tabs (design system 6.5.0; no Back to hub)
|
|
16
|
+
*
|
|
17
|
+
* Every row goes somewhere: to the tool's app, when the person holds it, or
|
|
18
|
+
* else to the tool's page in the Hub (`osHubPath`), built from the design's
|
|
19
|
+
* sample dashboards. A row is locked only when its tool has an app the person
|
|
20
|
+
* does not hold, or while the catalogue is still being asked.
|
|
10
21
|
*
|
|
11
22
|
* Pure data and pure functions: no React, no Supabase. An app that is not on
|
|
12
23
|
* the core imports this beside the design system's WorkspaceFrame; an app on
|
|
@@ -23,108 +34,160 @@ export const OS_FUNCTIONS = [
|
|
|
23
34
|
{ id: "commercial", label: "Commercial", icon: "commercial" },
|
|
24
35
|
{ id: "operations", label: "Operations", icon: "operations" },
|
|
25
36
|
];
|
|
37
|
+
const tool = (id, label, icon, status, tabs) => (tabs ? { id, label, icon, status, tabs: tabs.map(([tab, name]) => ({ id: tab, label: name })) } : { id, label, icon, status });
|
|
38
|
+
const overview = (fn) => ({
|
|
39
|
+
title: "",
|
|
40
|
+
items: [{ id: `${fn}-home`, label: "Overview", icon: "hub-overview", status: "No status", overview: true }],
|
|
41
|
+
});
|
|
26
42
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
43
|
+
* Cliff's menu map (the design's ui_kits/functions dashboards/nav.js and
|
|
44
|
+
* data.js, 16 October 2026): its ids, labels, groups, order, status and
|
|
45
|
+
* views, an Overview at the top of Finance, Commercial and Operations, and
|
|
46
|
+
* the two rows the design keeps from before its merge (Customer scorecard,
|
|
47
|
+
* Clearance list). Then our four Live apps the map does not have, at the end
|
|
48
|
+
* of their groups, so they stay reachable: Shelf simulator (Marketing >
|
|
29
49
|
* Planning), Key accounts (Commercial > Planning), PM Copilot and Candidate
|
|
30
|
-
* hub (Operations > Planning)
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
50
|
+
* hub (Operations > Planning); they borrow ops-inventory-value (a stocked
|
|
51
|
+
* shelf), com-customer-scorecard, hub-tasks and hub-accounts. Owner, source
|
|
52
|
+
* and cadence stay in the sheet. Icons are glyph ids from the design
|
|
53
|
+
* system's NAV_ICONS, which draws them inline. Ids renamed in 0.3.0 are in
|
|
54
|
+
* OS_TOOL_ALIASES.
|
|
34
55
|
*/
|
|
35
56
|
export const OS_MENU = {
|
|
36
57
|
finance: [
|
|
58
|
+
overview("finance"),
|
|
37
59
|
{ title: "Reporting", items: [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
tool("cash-forecast", "Cash & forecast", "fin-cash", "In progress", [["cf-forecast", "13-week forecast"], ["cf-accuracy", "Forecast accuracy"], ["cf-manual", "Manual flows"]]),
|
|
61
|
+
tool("pl-vs-ly", "P&L vs LY", "fin-pl", "In progress", [["pl", "P&L"], ["pl-trend", "13-month trend"], ["pl-unmapped", "Unmapped accounts"]]),
|
|
62
|
+
tool("balance-sheet", "Balance sheet v LY", "fin-balance", "In progress", [["bs", "Balance sheet"], ["bs-ic", "Intercompany"]]),
|
|
63
|
+
tool("inventory-value", "Inventory valuation", "ops-inventory-value", "Live", [["val-summary", "Summary"], ["val-items", "By item"], ["val-gl", "GL reconciliation"]]),
|
|
64
|
+
tool("working-capital", "Working capital", "fin-capital", "In progress", [["wc-summary", "Actual & forecast"], ["wc-roi", "Inventory ROI"], ["wc-slow", "Aged & slow stock"]]),
|
|
65
|
+
tool("margin-by-channel", "Margin by channel", "fin-margin", "In progress", [["gm-channel", "By channel"], ["gm-bottom", "Bottom 20"], ["gm-recon", "Reconciliation"]]),
|
|
66
|
+
tool("debtors-creditors", "Debtors & creditors", "fin-debtors", "In progress", [["ar", "Debtors"], ["ap", "Creditors"], ["collect", "Collections"]]),
|
|
67
|
+
tool("sales-ratios", "Sales ratios", "fin-ratios", "In progress", [["ratios", "Scorecard"]]),
|
|
68
|
+
tool("board-pack", "Board pack", "fin-board-pack", "In progress", [["bp-summary", "Executive summary"], ["bp-build", "Build & sign off"]]),
|
|
44
69
|
] },
|
|
45
70
|
{ title: "Planning", items: [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
71
|
+
tool("month-end-close", "Month-end close", "fin-compliance", "No status"),
|
|
72
|
+
tool("budget-reforecast", "Budget & reforecast", "fin-capital", "No status"),
|
|
73
|
+
tool("cost-sheets", "Cost sheets", "fin-margin", "No status"),
|
|
74
|
+
tool("approvals-authority", "Approvals & authority", "fin-approvals", "No status"),
|
|
75
|
+
tool("compliance-calendar", "Compliance calendar", "fin-compliance", "No status"),
|
|
51
76
|
] },
|
|
52
77
|
],
|
|
53
78
|
marketing: [
|
|
54
79
|
{ title: "Performance", items: [
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
80
|
+
tool("live-ecomm-sales", "Live eComm sales by store", "mkt-live-ecomm-sales-by-store", "Live"),
|
|
81
|
+
tool("paid-media", "Paid media", "mkt-paid-media", "No status"),
|
|
82
|
+
tool("email-sms", "Email & SMS", "mkt-email-sms", "No status"),
|
|
83
|
+
tool("retention-ltv", "Retention & LTV", "mkt-retention-ltv", "No status"),
|
|
84
|
+
tool("social-influencer", "Social & influencer", "mkt-social-influencer", "No status"),
|
|
85
|
+
tool("spend-vs-budget", "Spend vs budget", "mkt-spend-vs-budget", "No status"),
|
|
61
86
|
] },
|
|
62
87
|
{ title: "Planning", items: [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
88
|
+
tool("marketing-calendar", "Marketing calendar", "mkt-marketing-calendar", "No status"),
|
|
89
|
+
tool("social-content-planner", "Social media content planner", "mkt-media-content-planner", "No status"),
|
|
90
|
+
tool("influencer-crm", "Influencer CRM", "mkt-influencer-crm", "No status"),
|
|
91
|
+
tool("franks-kitchen", "Influencer Manager", "mkt-frank-s-kitchen", "In progress"),
|
|
92
|
+
tool("brand-guidelines", "Brand guidelines", "mkt-brand-guidelines", "In progress"),
|
|
93
|
+
tool("npd-validator", "NPD validator", "mkt-npd-validator", "Live"),
|
|
94
|
+
tool("pricing-researcher", "Pricing researcher", "mkt-pricing-researcher", "Live"),
|
|
95
|
+
tool("shelf-simulator", "Shelf simulator", "ops-inventory-value", "Live"),
|
|
71
96
|
] },
|
|
72
97
|
{ title: "Creative", items: [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
98
|
+
tool("image-generator", "Artificial Design Studio", "mkt-image-generator", "Live"),
|
|
99
|
+
tool("retail-image-library", "Asset Manager", "mkt-retail-ecom-image-library", "Live"),
|
|
100
|
+
tool("brand-voice-copywriter", "Brand voice copywriter", "mkt-brand-voice-copywriter", "Live"),
|
|
76
101
|
] },
|
|
77
102
|
],
|
|
78
103
|
commercial: [
|
|
104
|
+
overview("commercial"),
|
|
79
105
|
{ title: "Reporting", items: [
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{ id: "at-risk-customers", label: "At risk / lapsed customers", icon: "com-at-risk-lapsed-customers", status: "To build" },
|
|
106
|
+
tool("sales", "Sales", "com-sales-by-channel", "Live", [["overview", "Overview"], ["customer", "By customer"], ["item", "By item"]]),
|
|
107
|
+
tool("open-orders", "Open orders", "com-open-so-s", "Live", [["open", "Open"], ["held", "Held"], ["due", "Due this week"]]),
|
|
108
|
+
tool("retailer-sell-out", "Retailer sell out (POS)", "com-retailer-sell-out-pos", "In progress", [["sell-through", "Sell in vs sell out"], ["cover", "Retailer stock cover"], ["ranging", "Ranging"]]),
|
|
109
|
+
tool("customers", "Customers", "com-customer-funnel", "In progress", [["new", "New"], ["at-risk", "At risk"], ["lapsed", "Lapsed"]]),
|
|
85
110
|
] },
|
|
86
111
|
{ title: "Planning", items: [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
112
|
+
tool("customer-forecast", "Customer forecast collaboration", "ops-forecast-accuracy", "In progress", [["lines", "Lines to decide"], ["cycle", "This cycle"]]),
|
|
113
|
+
tool("pricelist-generator", "Pricelist generator", "com-pricelist-generator", "To build"),
|
|
114
|
+
tool("margin-calculator", "Margin calculator", "com-margin-calculator", "In progress"),
|
|
115
|
+
tool("trade-marketing-calendar", "Trade marketing calendar", "com-trade-marketing-calendar", "To build"),
|
|
116
|
+
tool("line-form-populator", "New line form populator", "com-line-form-populator", "In progress"),
|
|
117
|
+
tool("crm", "CRM", "com-crm", "Live"),
|
|
118
|
+
tool("customer-scorecard", "Customer scorecard", "com-customer-scorecard", "No status"),
|
|
119
|
+
tool("clearance-list", "Clearance list", "com-clearance-list", "No status"),
|
|
120
|
+
tool("key-accounts", "Key accounts", "com-customer-scorecard", "Live"),
|
|
94
121
|
] },
|
|
95
122
|
],
|
|
96
123
|
operations: [
|
|
124
|
+
overview("operations"),
|
|
97
125
|
{ title: "Reporting", items: [
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{ id: "inventory-value", label: "Inventory value by item", icon: "ops-inventory-value", status: "Live" },
|
|
126
|
+
tool("inventory-health", "Inventory health", "ops-inventory-health", "Live", [["health", "Health"], ["aging", "Aging & clearance"], ["locations", "Stock by location"]]),
|
|
127
|
+
tool("out-of-stocks", "Out of stocks", "ops-oos", "Live", [["oos-now", "Out now"], ["oos-history", "History"]]),
|
|
128
|
+
tool("forecast-accuracy", "Forecast accuracy", "ops-forecast-accuracy", "In progress", [["fc-accuracy", "Accuracy"], ["fc-items", "By item"], ["fc-compare", "Forecast vs actual"]]),
|
|
129
|
+
tool("open-purchase-orders", "Open purchase orders", "ops-open-po-s", "Live", [["po-all", "Purchase orders"]]),
|
|
130
|
+
tool("shipment-tracker", "Shipment tracker", "ops-shipment-tracker", "Live", [["ship-all", "Shipments"]]),
|
|
131
|
+
tool("order-otif", "Order OTIF", "ops-customer-otif", "In progress", [["otif", "Order OTIF"]]),
|
|
105
132
|
] },
|
|
106
133
|
{ title: "Planning", items: [
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
134
|
+
tool("action-queue", "Action queue", "ops-action-queue", "Live", [["queue-mine", "My queue"], ["queue-team", "Team"]]),
|
|
135
|
+
tool("demand-planning", "Demand planning", "ops-demand-plan", "In progress", [["dp-plan", "Plan"], ["dp-cleanse", "Cleanse history"], ["dp-accuracy", "Accuracy"], ["dp-lifecycle", "New & EOL"], ["dp-versions", "Versions"]]),
|
|
136
|
+
tool("ordering-tool", "Ordering tool", "ops-order-planing", "Live", [["order-suggest", "Suggestions"], ["order-draft", "Draft"], ["order-approvals", "Approvals"]]),
|
|
137
|
+
tool("carton-label-generator", "Carton label generator", "ops-carton-label-generator", "Live"),
|
|
138
|
+
tool("pm-copilot", "PM Copilot", "hub-tasks", "Live"),
|
|
139
|
+
tool("candidate-hub", "Candidate hub", "hub-accounts", "Live"),
|
|
113
140
|
] },
|
|
114
141
|
],
|
|
115
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* Ids the menu map had before 0.3.0, and the row each is now: an app that
|
|
145
|
+
* still passes one (a tool of its own, a link, a reason it is locked) lands
|
|
146
|
+
* on the new row. Inventory value kept its id and moved to Finance, as
|
|
147
|
+
* Inventory valuation.
|
|
148
|
+
*/
|
|
149
|
+
export const OS_TOOL_ALIASES = {
|
|
150
|
+
"pl-vs-budget": "pl-vs-ly",
|
|
151
|
+
"live-sales-by-channel": "sales",
|
|
152
|
+
"customer-otif": "order-otif",
|
|
153
|
+
"new-customer-acquisition": "customers",
|
|
154
|
+
"at-risk-customers": "customers",
|
|
155
|
+
};
|
|
156
|
+
/** The menu map's id for `id`: itself, or the row an id from before 0.3.0 is now. */
|
|
157
|
+
export function osToolId(id) {
|
|
158
|
+
return Object.prototype.hasOwnProperty.call(OS_TOOL_ALIASES, id) ? OS_TOOL_ALIASES[id] : id;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The page in the Hub where a row with no app of its own goes (0.3.0): the
|
|
162
|
+
* function's overview (`/os/finance`), a tool's page (`/os/finance/cash-forecast`)
|
|
163
|
+
* or one of its views (`/os/finance/cash-forecast?tab=cf-accuracy`). The Hub
|
|
164
|
+
* builds these pages from the design's sample dashboards. A path in the Hub:
|
|
165
|
+
* other apps reach it through HUB_URL.
|
|
166
|
+
*/
|
|
167
|
+
export function osHubPath(fn, toolId, tab) {
|
|
168
|
+
let path = `/os/${encodeURIComponent(fn)}`;
|
|
169
|
+
if (toolId)
|
|
170
|
+
path += `/${encodeURIComponent(toolId)}`;
|
|
171
|
+
if (tab)
|
|
172
|
+
path += `?tab=${encodeURIComponent(tab)}`;
|
|
173
|
+
return path;
|
|
174
|
+
}
|
|
116
175
|
/* Ops Hub is linked, not federated (CONTRACT.md): its catalogue row decides
|
|
117
176
|
who sees its tools live; the fixed address serves frames off the core. */
|
|
118
177
|
const OPS_HUB = "https://frankhub.lovable.app";
|
|
119
178
|
const opsHub = (path) => ({ app: "ops_hub", url: OPS_HUB, path });
|
|
120
179
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
180
|
+
* The tools that have an app of their own: every Live tool's, unchanged in
|
|
181
|
+
* 0.3.0 but for the new ids (Sales was live-sales-by-channel; Inventory
|
|
182
|
+
* valuation, in Finance now, keeps inventory-value), and the tools whose app
|
|
183
|
+
* the catalogue already has whatever the map says of them (Influencer
|
|
184
|
+
* Manager, Marketing calendar, Paid media), so every app the app switcher
|
|
185
|
+
* offers is reachable from the menu too. Every link opens in the same tab.
|
|
186
|
+
* Label Maker's fixed address is label-maker.autosolutions.app since 0.3.1:
|
|
187
|
+
* the old label-maker-app.lovable.app address cannot read the shared session.
|
|
188
|
+
* Pricing researcher and Brand voice copywriter have no app to open yet:
|
|
189
|
+
* like every tool with none, they open their page in the Hub. The Hub itself
|
|
190
|
+
* (smart_comms_hub) is the rail's Hub, not a row.
|
|
128
191
|
*/
|
|
129
192
|
export const OS_TOOL_LINKS = {
|
|
130
193
|
"live-ecomm-sales": { app: "alive_reporting" },
|
|
@@ -137,7 +200,7 @@ export const OS_TOOL_LINKS = {
|
|
|
137
200
|
"image-generator": { app: "frank_create" },
|
|
138
201
|
"retail-image-library": { app: "asset_portal" },
|
|
139
202
|
"brand-voice-copywriter": {},
|
|
140
|
-
"
|
|
203
|
+
"sales": opsHub("/sales-dashboard"),
|
|
141
204
|
"open-orders": opsHub("/customer-orders"),
|
|
142
205
|
"crm": { app: "enxgy_crm", url: "https://e-crm.autosolutions.app" },
|
|
143
206
|
"key-accounts": { app: "key_accounts", url: "https://key-accounts.lovable.app" },
|
|
@@ -148,12 +211,10 @@ export const OS_TOOL_LINKS = {
|
|
|
148
211
|
"inventory-value": opsHub("/inventory-health?view=valuation"),
|
|
149
212
|
"action-queue": opsHub("/action-queue"),
|
|
150
213
|
"ordering-tool": opsHub("/ordering"),
|
|
151
|
-
"carton-label-generator": { app: "label_maker", url: "https://label-maker
|
|
214
|
+
"carton-label-generator": { app: "label_maker", url: "https://label-maker.autosolutions.app" },
|
|
152
215
|
"pm-copilot": { app: "pm_copilot", url: "https://pm-copilot.autosolutions.app" },
|
|
153
216
|
"candidate-hub": { app: "candidate_hub" },
|
|
154
217
|
};
|
|
155
|
-
/* Each tool's status in the map, for catalogueLinks. */
|
|
156
|
-
const STATUS = new Map(Object.values(OS_MENU).flatMap((groups) => groups.flatMap((group) => group.items.map((tool) => [tool.id, tool.status]))));
|
|
157
218
|
/** The Hub's own pages, for the rail's Hub, Admin and Settings rows in other apps. */
|
|
158
219
|
export const HUB_PATHS = {
|
|
159
220
|
home: "/comms/overview",
|
|
@@ -161,9 +222,11 @@ export const HUB_PATHS = {
|
|
|
161
222
|
settings: "/comms/settings",
|
|
162
223
|
};
|
|
163
224
|
/**
|
|
164
|
-
* Why a row is locked.
|
|
165
|
-
*
|
|
166
|
-
*
|
|
225
|
+
* Why a row is locked. Since 0.3.0 a row is locked only when its tool has an
|
|
226
|
+
* app the person does not hold (`locked`), or while os_context() has not
|
|
227
|
+
* answered yet, or failed and is being asked again (`checking`): every other
|
|
228
|
+
* row opens its app or its page in the Hub. `notBuilt` and `notLinked` are no
|
|
229
|
+
* longer drawn by the frame, and stay for code that reads them.
|
|
167
230
|
*/
|
|
168
231
|
export const HINTS = {
|
|
169
232
|
locked: "Ask your company admin to switch this on for you",
|
|
@@ -181,60 +244,77 @@ export function osFooter({ admin = false } = {}) {
|
|
|
181
244
|
}
|
|
182
245
|
/**
|
|
183
246
|
* Tool id to address, for the tools with a fixed `url`: what a frame off the
|
|
184
|
-
* core, which has no catalogue to ask, can link to. No tenant hint.
|
|
247
|
+
* core, which has no catalogue to ask, can link to. No tenant hint. Every
|
|
248
|
+
* other row of such a frame opens its page in the Hub, through HUB_URL.
|
|
185
249
|
*/
|
|
186
250
|
export function staticLinks() {
|
|
187
251
|
const out = {};
|
|
188
|
-
for (const [
|
|
252
|
+
for (const [id, link] of Object.entries(OS_TOOL_LINKS))
|
|
189
253
|
if (link.url)
|
|
190
|
-
out[
|
|
254
|
+
out[id] = joinPath(link.url, link.path);
|
|
191
255
|
return out;
|
|
192
256
|
}
|
|
193
257
|
/**
|
|
194
258
|
* Tool id to address, and tool id to the reason a row is off, for
|
|
195
259
|
* OsWorkspaceFrame to pass to osFrame. `apps` is os_context().apps: the apps
|
|
196
260
|
* this person holds in the acting company, as the app switcher lists them.
|
|
197
|
-
* For a tool whose OS_TOOL_LINKS entry names an app
|
|
261
|
+
* For a tool whose OS_TOOL_LINKS entry names an app, whatever status the map
|
|
262
|
+
* gives the tool:
|
|
198
263
|
* - held, with an address: linked to it (plus `path`), with the company as
|
|
199
|
-
* ?tenant=,
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* - not held: a Live tool is locked ("Ask your company admin to switch this
|
|
204
|
-
* on for you"); any other keeps the map's own status (Not built yet, In
|
|
205
|
-
* progress, To build).
|
|
264
|
+
* ?tenant=, because the switcher already offers that app;
|
|
265
|
+
* - held, not deployed yet (no address): neither, so the frame opens the
|
|
266
|
+
* tool's page in the Hub, as it does for a tool with no app;
|
|
267
|
+
* - not held: locked ("Ask your company admin to switch this on for you").
|
|
206
268
|
* A fixed `url` is never consulted here: it is no way round the catalogue.
|
|
207
|
-
* Tools with no app
|
|
208
|
-
* nothing to them.
|
|
269
|
+
* Tools with no app open their page in the Hub (osFrame). Links are final:
|
|
270
|
+
* osFrame adds nothing to them.
|
|
209
271
|
*
|
|
210
272
|
* With `apps` null (the catalogue has not answered yet, or the read failed
|
|
211
|
-
* and is being asked again), nothing is linked, and
|
|
212
|
-
* reads "Checking your access…" rather than claiming it is
|
|
213
|
-
* held; any other keeps the map's own status.
|
|
273
|
+
* and is being asked again), nothing is linked, and every tool with an app
|
|
274
|
+
* reads "Checking your access…" rather than claiming it is held or not.
|
|
214
275
|
*/
|
|
215
276
|
export function catalogueLinks(apps, tenantSlug = null) {
|
|
216
277
|
const links = {};
|
|
217
278
|
const locked = {};
|
|
218
|
-
for (const [
|
|
279
|
+
for (const [id, link] of Object.entries(OS_TOOL_LINKS)) {
|
|
219
280
|
if (!link.app)
|
|
220
281
|
continue;
|
|
221
282
|
if (apps === null) {
|
|
222
|
-
|
|
223
|
-
locked[tool] = HINTS.checking;
|
|
283
|
+
locked[id] = HINTS.checking;
|
|
224
284
|
continue;
|
|
225
285
|
}
|
|
226
286
|
const app = apps.find((candidate) => candidate.key === link.app);
|
|
227
287
|
if (app?.url)
|
|
228
|
-
links[
|
|
229
|
-
else if (
|
|
230
|
-
|
|
231
|
-
else if (app)
|
|
232
|
-
locked[tool] = HINTS.notLinked;
|
|
233
|
-
else
|
|
234
|
-
locked[tool] = HINTS.locked;
|
|
288
|
+
links[id] = withTenantHint(joinPath(app.url, link.path), tenantSlug);
|
|
289
|
+
else if (!app)
|
|
290
|
+
locked[id] = HINTS.locked;
|
|
235
291
|
}
|
|
236
292
|
return { links, locked };
|
|
237
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* The Hub's panel (0.3.0), the design's: Smart Comms Hub, its eight views,
|
|
296
|
+
* then the Assistants. Every app shows it when the rail's Hub is selected,
|
|
297
|
+
* each row a link to its page in the Hub (in the Hub, its own route). The Hub
|
|
298
|
+
* may pass rows of its own instead (`hubItems`), to lock the Assistants it
|
|
299
|
+
* gates.
|
|
300
|
+
*/
|
|
301
|
+
export const OS_HUB_MENU = [
|
|
302
|
+
{ title: "Smart Comms Hub", items: [
|
|
303
|
+
{ id: "overview", label: "Overview", icon: "hub-overview", path: "/comms/overview", match: ["/comms"] },
|
|
304
|
+
{ id: "inbox", label: "Inbox", icon: "hub-inbox", path: "/comms/inbox" },
|
|
305
|
+
{ id: "calendar", label: "Calendar", icon: "hub-calendar", path: "/comms/calendar" },
|
|
306
|
+
{ id: "tasks", label: "Tasks", icon: "hub-tasks", path: "/comms/tasks" },
|
|
307
|
+
{ id: "slack", label: "Slack", icon: "hub-slack", path: "/comms/slack" },
|
|
308
|
+
{ id: "monday", label: "Monday", icon: "hub-monday", path: "/comms/monday" },
|
|
309
|
+
{ id: "accounts", label: "Accounts", icon: "hub-accounts", path: "/comms/accounts" },
|
|
310
|
+
{ id: "configuration", label: "Configuration", icon: "hub-configuration", path: "/comms/settings" },
|
|
311
|
+
] },
|
|
312
|
+
{ title: "Assistants", items: [
|
|
313
|
+
{ id: "agent", label: "Unmarked Agent", icon: "agent", path: "/comms/agent" },
|
|
314
|
+
{ id: "voice", label: "Brand Voice Capture", icon: "brandvoice", path: "/launcher?section=brandvoice" },
|
|
315
|
+
{ id: "signature", label: "Signature Generator", icon: "mkt-brand-voice-copywriter", path: "/launcher?section=signature" },
|
|
316
|
+
] },
|
|
317
|
+
];
|
|
238
318
|
const ORIGIN = "http://os.invalid";
|
|
239
319
|
function joinPath(base, path) {
|
|
240
320
|
if (!path)
|
|
@@ -249,6 +329,21 @@ function joinPath(base, path) {
|
|
|
249
329
|
function trimmed(pathname) {
|
|
250
330
|
return pathname.replace(/\/+$/, "") || "/";
|
|
251
331
|
}
|
|
332
|
+
/* A map from an app keyed by tool id, under the menu's ids: an entry under an
|
|
333
|
+
id from before 0.3.0 lands on the row it is now, unless the new id has an
|
|
334
|
+
entry of its own. */
|
|
335
|
+
function underMenuIds(map) {
|
|
336
|
+
const out = {};
|
|
337
|
+
for (const [id, value] of Object.entries(map))
|
|
338
|
+
if (osToolId(id) === id)
|
|
339
|
+
out[id] = value;
|
|
340
|
+
for (const [id, value] of Object.entries(map)) {
|
|
341
|
+
const now = osToolId(id);
|
|
342
|
+
if (now !== id && !Object.prototype.hasOwnProperty.call(out, now))
|
|
343
|
+
out[now] = value;
|
|
344
|
+
}
|
|
345
|
+
return out;
|
|
346
|
+
}
|
|
252
347
|
/**
|
|
253
348
|
* How specifically `route` claims `location`: [path length, query params], or
|
|
254
349
|
* null when it does not. Paths compare without regard to case, as the routers
|
|
@@ -293,49 +388,66 @@ function best(routes, location, exact = false) {
|
|
|
293
388
|
* company, the footer, and the only routing logic the frame needs.
|
|
294
389
|
*/
|
|
295
390
|
export function osFrame(options) {
|
|
296
|
-
const { appKey, tools = [], hubItems,
|
|
391
|
+
const { appKey, tools = [], hubItems, admin = false, settingsPath, hubUrl = HUB_URL, tenantSlug = null, } = options;
|
|
392
|
+
const links = underMenuIds(options.links ?? {});
|
|
393
|
+
const locked = underMenuIds(options.locked ?? {});
|
|
297
394
|
const isHub = appKey === "hub";
|
|
298
395
|
const homePath = options.homePath ?? (isHub ? HUB_PATHS.home : "/");
|
|
299
|
-
const own = new Map(tools.map((
|
|
396
|
+
const own = new Map(tools.map((mine) => [osToolId(mine.id), mine]));
|
|
300
397
|
const toHub = (path) => ({ href: withTenantHint(`${hubUrl}${path}`, tenantSlug), external: true });
|
|
398
|
+
/* A path in the Hub: in the Hub one of its own routes, elsewhere a link. */
|
|
399
|
+
const inHub = (base, path, match) => (isHub
|
|
400
|
+
? { ...base, path, ...(match ? { match } : {}) }
|
|
401
|
+
: { ...base, href: withTenantHint(`${hubUrl}${path}`, tenantSlug) });
|
|
301
402
|
const sections = {};
|
|
302
|
-
|
|
303
|
-
|
|
403
|
+
const hubMenu = hubItems ?? OS_HUB_MENU;
|
|
404
|
+
if (hubMenu.length) {
|
|
405
|
+
sections["hub"] = hubItems
|
|
406
|
+
? hubItems.map((section) => ({ ...section, items: [...section.items] }))
|
|
407
|
+
: OS_HUB_MENU.map((section) => ({
|
|
408
|
+
...(section.title ? { title: section.title } : {}),
|
|
409
|
+
items: section.items.map((row) => inHub({ id: row.id, label: row.label, ...(row.icon ? { icon: row.icon } : {}) }, row.path ?? HUB_PATHS.home, row.match)),
|
|
410
|
+
}));
|
|
411
|
+
}
|
|
304
412
|
for (const [fn, groups] of Object.entries(OS_MENU)) {
|
|
305
413
|
sections[fn] = groups.map((group) => ({
|
|
306
|
-
title: group.title,
|
|
307
|
-
items: group.items.map((
|
|
308
|
-
const
|
|
309
|
-
const
|
|
414
|
+
...(group.title ? { title: group.title } : {}),
|
|
415
|
+
items: group.items.map((entry) => {
|
|
416
|
+
const base = { id: entry.id, label: entry.label, icon: entry.icon };
|
|
417
|
+
const mine = own.get(entry.id);
|
|
310
418
|
if (mine)
|
|
311
419
|
return rowFor(base, mine);
|
|
312
|
-
/*
|
|
313
|
-
the
|
|
314
|
-
const
|
|
420
|
+
/* Its page in the Hub, which in the Hub also places a location there
|
|
421
|
+
on this row when the row itself opens an app. */
|
|
422
|
+
const page = osHubPath(fn, entry.overview ? null : entry.id);
|
|
423
|
+
/* A link or a reason from the catalogue comes first: the catalogue
|
|
424
|
+
knows what this person holds. */
|
|
425
|
+
const href = links[entry.id];
|
|
315
426
|
if (href)
|
|
316
|
-
return { ...base, href };
|
|
317
|
-
const reason = locked[
|
|
427
|
+
return { ...base, ...(isHub ? { match: [page] } : {}), href };
|
|
428
|
+
const reason = locked[entry.id];
|
|
318
429
|
if (reason)
|
|
319
430
|
return { ...base, disabled: true, title: reason };
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
431
|
+
/* No app of its own (or one this frame cannot reach: off the core
|
|
432
|
+
with no fixed address, or held and not deployed yet): its page in
|
|
433
|
+
the Hub. */
|
|
434
|
+
return inHub(base, page);
|
|
323
435
|
}),
|
|
324
436
|
}));
|
|
325
437
|
}
|
|
326
438
|
/* This app's tools the menu map does not have, placed where the app says. */
|
|
327
|
-
const mapped = new Set(Object.values(OS_MENU).flatMap((groups) => groups.flatMap((group) => group.items.map((
|
|
328
|
-
for (const
|
|
329
|
-
if (mapped.has(
|
|
439
|
+
const mapped = new Set(Object.values(OS_MENU).flatMap((groups) => groups.flatMap((group) => group.items.map((entry) => entry.id))));
|
|
440
|
+
for (const mine of tools) {
|
|
441
|
+
if (mapped.has(osToolId(mine.id)) || !mine.fn)
|
|
330
442
|
continue;
|
|
331
|
-
const list = sections[
|
|
332
|
-
const title =
|
|
443
|
+
const list = sections[mine.fn] ?? (sections[mine.fn] = []);
|
|
444
|
+
const title = mine.section;
|
|
333
445
|
let section = list.find((candidate) => candidate.title === title);
|
|
334
446
|
if (!section) {
|
|
335
447
|
section = title === undefined ? { items: [] } : { title, items: [] };
|
|
336
448
|
list.push(section);
|
|
337
449
|
}
|
|
338
|
-
section.items.push(rowFor({ id:
|
|
450
|
+
section.items.push(rowFor({ id: mine.id, label: mine.label ?? mine.id, ...(mine.icon ? { icon: mine.icon } : {}) }, mine));
|
|
339
451
|
}
|
|
340
452
|
const footerItems = osFooter({ admin });
|
|
341
453
|
/* Every place a location can land, most specific claim wins; on a tie, the
|
|
@@ -360,7 +472,7 @@ export function osFrame(options) {
|
|
|
360
472
|
}
|
|
361
473
|
}
|
|
362
474
|
}
|
|
363
|
-
const landingFn = tools.map((
|
|
475
|
+
const landingFn = tools.map((mine) => fnOf(sections, osToolId(mine.id))).find((fn) => fn !== undefined);
|
|
364
476
|
const locate = (location) => {
|
|
365
477
|
let url;
|
|
366
478
|
try {
|
|
@@ -418,8 +530,12 @@ export function osFrame(options) {
|
|
|
418
530
|
if (!row) {
|
|
419
531
|
if (fn !== "hub")
|
|
420
532
|
return null; // opening a function's menu is not a navigation
|
|
421
|
-
if (!isHub)
|
|
422
|
-
|
|
533
|
+
if (!isHub) {
|
|
534
|
+
/* The rail's Hub with a menu (the Hub panel, 0.3.0) opens it, as any
|
|
535
|
+
function does; with none (`hubItems: []`), and Back to hub, it
|
|
536
|
+
goes to the Hub. */
|
|
537
|
+
return !state.back && (sections[fn]?.length ?? 0) > 0 ? null : toHub(HUB_PATHS.home);
|
|
538
|
+
}
|
|
423
539
|
/* The rail's Hub where the person is already in the Hub (a thread, a
|
|
424
540
|
tool, the landing) reopens its menu on that page: it is the menu's
|
|
425
541
|
control, never a navigation. Back to hub, and the rail's Hub from
|
|
@@ -455,18 +571,18 @@ export function osFrame(options) {
|
|
|
455
571
|
};
|
|
456
572
|
return { functions: OS_FUNCTIONS, sections, footerItems, homeFunction: "hub", locate, targetFor };
|
|
457
573
|
}
|
|
458
|
-
function rowFor(base,
|
|
574
|
+
function rowFor(base, mine) {
|
|
459
575
|
const row = { ...base };
|
|
460
|
-
if (
|
|
461
|
-
row.path =
|
|
462
|
-
if (
|
|
463
|
-
row.match =
|
|
464
|
-
if (
|
|
465
|
-
row.tabs =
|
|
466
|
-
if (
|
|
467
|
-
row.menu =
|
|
468
|
-
if (
|
|
469
|
-
row.badge =
|
|
576
|
+
if (mine.path)
|
|
577
|
+
row.path = mine.path;
|
|
578
|
+
if (mine.match)
|
|
579
|
+
row.match = mine.match;
|
|
580
|
+
if (mine.tabs)
|
|
581
|
+
row.tabs = mine.tabs;
|
|
582
|
+
if (mine.menu !== undefined)
|
|
583
|
+
row.menu = mine.menu;
|
|
584
|
+
if (mine.badge !== undefined)
|
|
585
|
+
row.badge = mine.badge;
|
|
470
586
|
return row;
|
|
471
587
|
}
|
|
472
588
|
/** Tabs as one list, whether given flat or in groups. */
|
package/dist/session.d.ts
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
/** Reassemble a chunked value from any source of name/value pairs. */
|
|
2
2
|
export declare function joinChunks(key: string, read: (name: string) => string | undefined): string | null;
|
|
3
|
+
export type SignedOut = {
|
|
4
|
+
expiresAt: number;
|
|
5
|
+
sessions: string[];
|
|
6
|
+
};
|
|
7
|
+
/** The sign-out note's value, read. autosolutions-os/federation reads it too, so the rule lives here once. */
|
|
8
|
+
export declare function parseSignedOutNote(raw: string | undefined): SignedOut | null;
|
|
9
|
+
/** A copy the sign-out ended: it expires no later than the sign-out's watermark, or it is one of the sessions it ended (a refresh of that session expires later). */
|
|
10
|
+
export declare function signedOutCopy(copy: Copy, note: SignedOut | null): boolean;
|
|
11
|
+
/** What the rules need from a stored session, or null when it is not one. */
|
|
12
|
+
export type Copy = {
|
|
13
|
+
raw: string;
|
|
14
|
+
expiresAt: number;
|
|
15
|
+
refreshToken: string;
|
|
16
|
+
userId: string | null;
|
|
17
|
+
sessionId: string | null;
|
|
18
|
+
};
|
|
19
|
+
export declare function parseCopy(raw: string | null | undefined): Copy | null;
|
|
3
20
|
/**
|
|
4
21
|
* Copy a session that arrived from another app into this origin's storage,
|
|
5
22
|
* or share this origin's when it is the newer one. Must run before the
|
|
@@ -40,4 +57,6 @@ export declare function followSharedSession(client: {
|
|
|
40
57
|
}, projectRef: string): void;
|
|
41
58
|
/** The storage key, for server code that needs to find the cookie by name. */
|
|
42
59
|
export declare function sharedSessionCookieName(projectRef: string): string;
|
|
60
|
+
/** The name of the note an explicit sign-out leaves, for code that follows the core from outside it (autosolutions-os/federation). */
|
|
61
|
+
export declare function signedOutCookieName(projectRef: string): string;
|
|
43
62
|
export {};
|