autosolutions-os 0.3.12 → 0.3.13

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 CHANGED
@@ -1,5 +1,43 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.13 - 2026-11-04
4
+
5
+ The Hub's permissions in every menu. The core now keeps one setting per
6
+ person, per company, per item of the menu (core migration hub_permissions,
7
+ 4 Nov 2026: View for a dashboard, Member or Admin for a tool), and
8
+ `os_context()` returns the items the person holds in the acting company.
9
+
10
+ ### autosolutions-os
11
+
12
+ - `OsContext.items` (optional): menu id to level (`OsItemLevel`, "view",
13
+ "member" or "admin"). Absent from a core older than the permissions.
14
+
15
+ ### autosolutions-os/nav
16
+
17
+ - `itemLocks(items)`: every row of the menu map the items do not name, with
18
+ "Ask your company admin to switch this on for you". Nothing while the core
19
+ has not answered (`null`) or for a core without items (`undefined`): the
20
+ rows stay as before, and the pages and the server check again.
21
+ - `withItemLocks(catalogueLinks(...), items)`: the catalogue's links and
22
+ locks with those applied. A row the person may not open is locked and never
23
+ a link, even when its app is held: Ops Hub serves thirteen rows, and holding
24
+ one of them holds the app. A reason the catalogue gave stays.
25
+
26
+ - `OS_HUB_ROW_ITEMS` and `hubPanelLocks(items)`: the default Hub panel's
27
+ rows the person may not open (the seven Smart Comms views need Smart Comms
28
+ Hub, each tool its own item, Configuration none), for osFrame's new
29
+ `hubLocked` option, used when no `hubItems` are passed: a locked panel row
30
+ is shown, disabled, and never a link.
31
+
32
+ ### autosolutions-os/frame and autosolutions-os/core-view
33
+
34
+ - `OsWorkspaceFrame` applies them, so a sample page, a Finance report, an
35
+ Ops Hub row or a Hub tool the person may not open is greyed in every app's
36
+ menu, with the reason, and does not open. `useCoreFrame` (Ops Hub, Asset
37
+ Portal) does the same from the Hub's session: its `frameOptions` carry
38
+ `hubLocked` and the item locks. An app needs no code change. The Hub's own
39
+ panel still comes from the Hub (`hubItems`).
40
+
3
41
  ## 0.3.12 - 2026-11-04
4
42
 
5
43
  A review of every tab after 0.3.11 found two rows that opened sample pages in
package/README.md CHANGED
@@ -134,6 +134,17 @@ import { OsWorkspaceFrame } from "autosolutions-os/frame";
134
134
  With no `search` the bar's field is the OS menu search. An app with a search
135
135
  of its own passes it: `search={{ placeholder: "Search", value: query, onChange: setQuery }}`.
136
136
 
137
+ Since 0.3.13 the frame greys every row the person may not open: the core's
138
+ `os_context()` returns `items`, the items of the menu they hold in the acting
139
+ company (the Hub's permissions: View for a dashboard, Member or Admin for a
140
+ tool), and every row it does not name is locked with "Ask your company admin
141
+ to switch this on for you", even when its app is held (Ops Hub serves thirteen
142
+ rows). Until the core answers, and with a core without `items`, nothing new
143
+ is locked (the pages and the server check again). `itemLocks(items)` and
144
+ `withItemLocks(catalogueLinks(...), items)` (`autosolutions-os/nav`) do the
145
+ same for a frame of your own, and `hubPanelLocks(items)` (osFrame's
146
+ `hubLocked`) greys the default Hub panel's rows the same way.
147
+
137
148
  It works with any router: it reads `location` and calls `onNavigate(href)` for
138
149
  paths inside the app, and opens other apps itself, in the same tab. The rows
139
150
  for other apps are links (`<a href>` with `?tenant=`), and so are this app's
package/dist/context.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type OsApp, type OsContext, type OsContextStatus, type OsTenant } from "./contextCache.js";
2
- export { loadOsContext, invalidateOsContext, refreshOsContext, retryOsContext, watchOsAuth, type OsApp, type OsContext, type OsContextStatus, type OsTenant, } from "./contextCache.js";
2
+ export { loadOsContext, invalidateOsContext, refreshOsContext, retryOsContext, watchOsAuth, type OsApp, type OsContext, type OsContextStatus, type OsItemLevel, type OsTenant, } from "./contextCache.js";
3
3
  /** The context and where it stands, for a component that shows the difference. */
4
4
  export declare function useOsContextState(os: unknown): {
5
5
  context: OsContext | null;
@@ -19,10 +19,18 @@ export type OsApp = {
19
19
  designKey: string | null;
20
20
  labelUrl: string | null;
21
21
  };
22
+ /** A person's level on one item of the OS menu (core migration hub_permissions). */
23
+ export type OsItemLevel = "view" | "member" | "admin";
22
24
  export type OsContext = {
23
25
  tenant: OsTenant | null;
24
26
  tenants: OsTenant[];
25
27
  apps: OsApp[];
28
+ /**
29
+ * The items of the OS menu this person may open in the acting company, by
30
+ * menu id (0.3.13): a dashboard's level is "view", a tool's "member" or
31
+ * "admin". Absent from a core older than the Hub's permissions (4 Nov 2026).
32
+ */
33
+ items?: Record<string, OsItemLevel>;
26
34
  };
27
35
  /**
28
36
  * Where a reader's context stands: still being read, read, or failed (and
@@ -36,6 +36,8 @@ export type CoreFrameSource = "core" | "checking" | "static";
36
36
  export type CoreFrameOptionsForOsFrame = {
37
37
  links: Record<string, string>;
38
38
  locked: Record<string, string>;
39
+ /** The default Hub panel's rows the person may not open (0.3.13). */
40
+ hubLocked: Record<string, string>;
39
41
  admin: boolean;
40
42
  tenantSlug: string | null;
41
43
  };
package/dist/coreView.js CHANGED
@@ -32,7 +32,7 @@ import { retryOsContext } from "./context.js";
32
32
  import { followOsPerson } from "./contextCache.js";
33
33
  import { createCoreViewClient, hubSession } from "./coreReader.js";
34
34
  import { myAdminScope } from "./identity.js";
35
- import { catalogueLinks, staticLinks } from "./nav.js";
35
+ import { catalogueLinks, hubPanelLocks, staticLinks, withItemLocks } from "./nav.js";
36
36
  import { useOsPlate } from "./plate.js";
37
37
  export { CORE_VIEW_FUNCTIONS, createCoreViewClient, hubSession, } from "./coreReader.js";
38
38
  /** How often a page that stays open looks at the shared cookie again, besides focus and coming back into view. */
@@ -118,12 +118,17 @@ export function useCoreFrame({ appKey, email, fallback, companySwitch = "os" })
118
118
  const slug = current?.slug ?? null;
119
119
  const frameOptions = useMemo(() => {
120
120
  if (source === "static") {
121
- return { links: staticLinks(fallback.tenantSlug), locked: {}, admin: false, tenantSlug: fallback.tenantSlug };
121
+ return { links: staticLinks(fallback.tenantSlug), locked: {}, hubLocked: {}, admin: false, tenantSlug: fallback.tenantSlug };
122
122
  }
123
- /* "checking": apps is null, so nothing is linked and other apps' rows read as being checked. */
124
- const { links, locked } = catalogueLinks(source === "core" ? apps ?? null : null, source === "core" ? slug : null);
125
- return { links, locked, admin: source === "core" && manages, tenantSlug: source === "core" ? slug : null };
126
- }, [source, apps, slug, manages, fallback.tenantSlug]);
123
+ /* "checking": apps is null, so nothing is linked and other apps' rows read as being checked.
124
+ The core's items then lock every row the person may not open (0.3.13). */
125
+ const items = source === "core" ? context?.items : undefined;
126
+ const { links, locked } = withItemLocks(catalogueLinks(source === "core" ? apps ?? null : null, source === "core" ? slug : null), items);
127
+ return {
128
+ links, locked, hubLocked: hubPanelLocks(items),
129
+ admin: source === "core" && manages, tenantSlug: source === "core" ? slug : null,
130
+ };
131
+ }, [source, apps, context?.items, slug, manages, fallback.tenantSlug]);
127
132
  const staticPlate = useMemo(() => ({
128
133
  ...(fallback.companySrc ? { companySrc: fallback.companySrc } : {}),
129
134
  ...(fallback.companyName ? { companyName: fallback.companyName } : {}),
package/dist/frame.js CHANGED
@@ -30,7 +30,7 @@ import { useCallback, useEffect, useId, useMemo, useState } from "react";
30
30
  import { TopBar, WorkspaceFrame } from "autosolutions-design-system";
31
31
  import { retryOsContext, watchOsAuth } from "./context.js";
32
32
  import { myAdminScope } from "./identity.js";
33
- import { catalogueLinks, osFrame } from "./nav.js";
33
+ import { catalogueLinks, hubPanelLocks, osFrame, withItemLocks } from "./nav.js";
34
34
  import { useOsPlate } from "./plate.js";
35
35
  import { useMenuSearch } from "./search.js";
36
36
  /* This app's own rows and tabs as links to their paths. Rows for other apps
@@ -92,19 +92,24 @@ export function OsWorkspaceFrame({ os, auth, appKey, tools, hubItems, location,
92
92
  void retryOsContext(os);
93
93
  }, [location]);
94
94
  const apps = context?.apps;
95
+ /* The items this person may open (0.3.13): null until the core answers,
96
+ undefined from a core older than the Hub's permissions. */
97
+ const items = context ? context.items : null;
95
98
  const slug = current?.slug ?? null;
96
99
  const frame = useMemo(() => {
97
100
  /* Only the catalogue says what this person holds. Until it arrives (or
98
101
  while a failed read is asked again) nothing is linked and nothing is
99
- "not held" or "not linked": other apps' tools read as being checked. */
100
- const { links, locked } = catalogueLinks(apps ?? null, slug);
102
+ "not held" or "not linked": other apps' tools read as being checked.
103
+ The items then lock every row the person may not open, whatever serves
104
+ it (0.3.13). */
105
+ const { links, locked } = withItemLocks(catalogueLinks(apps ?? null, slug), items);
101
106
  return osFrame({
102
107
  appKey, links, locked, admin: admin ?? manages, tenantSlug: slug,
103
108
  ...(tools ? { tools } : {}),
104
- ...(hubItems ? { hubItems } : {}),
109
+ ...(hubItems ? { hubItems } : { hubLocked: hubPanelLocks(items) }),
105
110
  ...(homePath ? { homePath } : {}),
106
111
  });
107
- }, [appKey, apps, admin, manages, slug, tools, hubItems, homePath]);
112
+ }, [appKey, apps, items, admin, manages, slug, tools, hubItems, homePath]);
108
113
  const linkTo = hrefFor === undefined ? (path) => path : hrefFor;
109
114
  const sections = useMemo(() => (linkTo ? linked(frame.sections, linkTo) : frame.sections), [frame, hrefFor]);
110
115
  /* `false` tells the frame a click went nowhere (Settings on the page
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { coreUrl, corePublishableKey, coreProjectRef, companyMarkUrl, appLabelUrl, HUB_URL, PARENT_DOMAIN } from "./config.js";
2
2
  export { createOsClient, resetOsClient, type OsClient } from "./client.js";
3
3
  export { adoptSharedSession, followSharedSession, publishSessionChanges, sharedSessionCookieName, joinChunks } from "./session.js";
4
- export { loadOsContext, invalidateOsContext, refreshOsContext, retryOsContext, watchOsAuth, useOsContext, useOsContextState, useTenant, useApps, groupApps, markFor, labelFor, withTenantHint, type OsContext, type OsContextStatus, type OsTenant, type OsApp, } from "./context.js";
4
+ export { loadOsContext, invalidateOsContext, refreshOsContext, retryOsContext, watchOsAuth, useOsContext, useOsContextState, useTenant, useApps, groupApps, markFor, labelFor, withTenantHint, type OsContext, type OsContextStatus, type OsItemLevel, type OsTenant, type OsApp, } from "./context.js";
5
5
  export { isEntitled, isActiveMember, appRole, appVariant, currentTenant, toolAllowed, myAdminScope, canManageCurrentCompany, type AdminScope, } from "./identity.js";
6
6
  export { OsAppSwitcher, OsAppSwitcherPlate, OsCompanySwitcher, OsBar, useCompanySwitch } from "./chrome.js";
7
7
  export { OsAuthGate, type OsAuthGateProps } from "./gate.js";
package/dist/nav.d.ts CHANGED
@@ -334,6 +334,45 @@ export declare function catalogueLinks(apps: ReadonlyArray<{
334
334
  links: Record<string, string>;
335
335
  locked: Record<string, string>;
336
336
  };
337
+ /**
338
+ * The rows of the menu map a person may not open (0.3.13). Since the core's
339
+ * permissions (migration hub_permissions, 4 Nov 2026) os_context().items
340
+ * names every item of the map the person holds in the acting company, a
341
+ * dashboard or a tool, whatever serves it; every row it does not name is
342
+ * locked, sample pages and Finance included, with "Ask your company admin to
343
+ * switch this on for you". Until the core has answered (`null`, or a read
344
+ * that failed and is being asked again), and from a core older than the
345
+ * permissions (`undefined`), nothing is locked here: the rows stay as they
346
+ * were before 0.3.13, the catalogue's own "Checking your access…" rows
347
+ * included, and the pages and the server check again.
348
+ */
349
+ export declare function itemLocks(items: Readonly<Record<string, string>> | null | undefined): Record<string, string>;
350
+ /**
351
+ * catalogueLinks' answer with itemLocks applied (0.3.13): a row the person may
352
+ * not open is locked even when its app is held, and is never a link. Ops Hub
353
+ * serves thirteen rows, and holding one of them holds the app. A reason the
354
+ * catalogue gave already stays.
355
+ */
356
+ export declare function withItemLocks(base: {
357
+ links: Record<string, string>;
358
+ locked: Record<string, string>;
359
+ }, items: Readonly<Record<string, string>> | null | undefined): {
360
+ links: Record<string, string>;
361
+ locked: Record<string, string>;
362
+ };
363
+ /**
364
+ * The Hub panel's rows and the item each needs (0.3.13): the seven Smart Comms
365
+ * views share Smart Comms Hub, each tool has its own, and Configuration
366
+ * (everyone's settings) needs none.
367
+ */
368
+ export declare const OS_HUB_ROW_ITEMS: Readonly<Record<string, string>>;
369
+ /**
370
+ * The rows of the default Hub panel (OS_HUB_MENU) a person may not open, by
371
+ * row id (0.3.13), for osFrame's `hubLocked`. As itemLocks: nothing while
372
+ * the core has not answered or has no items. The Hub passes its own panel
373
+ * (`hubItems`) and decides these itself.
374
+ */
375
+ export declare function hubPanelLocks(items: Readonly<Record<string, string>> | null | undefined): Record<string, string>;
337
376
  /** A route inside this app. `path` may carry a query, e.g. "/launcher?section=signature". */
338
377
  export type OsRoute = {
339
378
  /** Where a click goes. */
@@ -444,6 +483,11 @@ export type OsFrameOptions = {
444
483
  * goes to the Hub, as before 0.3.0.
445
484
  */
446
485
  hubItems?: OsHubSection[];
486
+ /**
487
+ * Row id of the default Hub panel to the reason it is off (hubPanelLocks,
488
+ * 0.3.13). Used only when `hubItems` is not given.
489
+ */
490
+ hubLocked?: Record<string, string>;
447
491
  /** Tool id to address, for tools served by other apps (catalogueLinks or staticLinks). Used as given. */
448
492
  links?: Record<string, string>;
449
493
  /** Tool id to the reason its row is off (catalogueLinks): wins over the tool's page in the Hub. */
package/dist/nav.js CHANGED
@@ -483,6 +483,80 @@ export function catalogueLinks(apps, tenantSlug = null) {
483
483
  }
484
484
  return { links, locked };
485
485
  }
486
+ /**
487
+ * The rows of the menu map a person may not open (0.3.13). Since the core's
488
+ * permissions (migration hub_permissions, 4 Nov 2026) os_context().items
489
+ * names every item of the map the person holds in the acting company, a
490
+ * dashboard or a tool, whatever serves it; every row it does not name is
491
+ * locked, sample pages and Finance included, with "Ask your company admin to
492
+ * switch this on for you". Until the core has answered (`null`, or a read
493
+ * that failed and is being asked again), and from a core older than the
494
+ * permissions (`undefined`), nothing is locked here: the rows stay as they
495
+ * were before 0.3.13, the catalogue's own "Checking your access…" rows
496
+ * included, and the pages and the server check again.
497
+ */
498
+ export function itemLocks(items) {
499
+ const out = {};
500
+ if (!items)
501
+ return out;
502
+ for (const groups of Object.values(OS_MENU)) {
503
+ for (const group of groups) {
504
+ for (const tool of group.items) {
505
+ if (!Object.prototype.hasOwnProperty.call(items, tool.id))
506
+ out[tool.id] = HINTS.locked;
507
+ }
508
+ }
509
+ }
510
+ return out;
511
+ }
512
+ /**
513
+ * catalogueLinks' answer with itemLocks applied (0.3.13): a row the person may
514
+ * not open is locked even when its app is held, and is never a link. Ops Hub
515
+ * serves thirteen rows, and holding one of them holds the app. A reason the
516
+ * catalogue gave already stays.
517
+ */
518
+ export function withItemLocks(base, items) {
519
+ const links = { ...base.links };
520
+ const locked = { ...base.locked };
521
+ for (const [id, reason] of Object.entries(itemLocks(items))) {
522
+ delete links[id];
523
+ locked[id] = locked[id] ?? reason;
524
+ }
525
+ return { links, locked };
526
+ }
527
+ /**
528
+ * The Hub panel's rows and the item each needs (0.3.13): the seven Smart Comms
529
+ * views share Smart Comms Hub, each tool has its own, and Configuration
530
+ * (everyone's settings) needs none.
531
+ */
532
+ export const OS_HUB_ROW_ITEMS = {
533
+ overview: "hub-comms",
534
+ inbox: "hub-comms",
535
+ calendar: "hub-comms",
536
+ tasks: "hub-comms",
537
+ slack: "hub-comms",
538
+ monday: "hub-comms",
539
+ accounts: "hub-comms",
540
+ agent: "hub-agent",
541
+ voice: "hub-voice",
542
+ signature: "hub-signature",
543
+ };
544
+ /**
545
+ * The rows of the default Hub panel (OS_HUB_MENU) a person may not open, by
546
+ * row id (0.3.13), for osFrame's `hubLocked`. As itemLocks: nothing while
547
+ * the core has not answered or has no items. The Hub passes its own panel
548
+ * (`hubItems`) and decides these itself.
549
+ */
550
+ export function hubPanelLocks(items) {
551
+ const out = {};
552
+ if (!items)
553
+ return out;
554
+ for (const [row, item] of Object.entries(OS_HUB_ROW_ITEMS)) {
555
+ if (!Object.prototype.hasOwnProperty.call(items, item))
556
+ out[row] = HINTS.locked;
557
+ }
558
+ return out;
559
+ }
486
560
  /**
487
561
  * The Hub's panel (0.3.0), the design's: Smart Comms Hub, its eight views,
488
562
  * then Tools (the owner's name since 0.3.9; Assistants before). Every app
@@ -580,7 +654,7 @@ function best(routes, location, exact = false) {
580
654
  * company, the footer, and the only routing logic the frame needs.
581
655
  */
582
656
  export function osFrame(options) {
583
- const { appKey, tools = [], hubItems, admin = false, hubUrl = HUB_URL, tenantSlug = null, } = options;
657
+ const { appKey, tools = [], hubItems, hubLocked = {}, admin = false, hubUrl = HUB_URL, tenantSlug = null, } = options;
584
658
  const links = underMenuIds(options.links ?? {});
585
659
  const locked = underMenuIds(options.locked ?? {});
586
660
  const isHub = appKey === "hub";
@@ -600,7 +674,12 @@ export function osFrame(options) {
600
674
  ? hubItems.map((section) => ({ ...section, items: [...section.items] }))
601
675
  : OS_HUB_MENU.map((section) => ({
602
676
  ...(section.title ? { title: section.title } : {}),
603
- items: section.items.map((row) => inHub({ id: row.id, label: row.label, ...(row.icon ? { icon: row.icon } : {}) }, row.path ?? HUB_PATHS.home, row.match)),
677
+ items: section.items.map((row) => {
678
+ const base = { id: row.id, label: row.label, ...(row.icon ? { icon: row.icon } : {}) };
679
+ /* A row the person may not open (0.3.13): shown, locked, never a link. */
680
+ const reason = hubLocked[row.id];
681
+ return reason ? { ...base, disabled: true, title: reason } : inHub(base, row.path ?? HUB_PATHS.home, row.match);
682
+ }),
604
683
  }));
605
684
  }
606
685
  for (const [fn, groups] of Object.entries(OS_MENU)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autosolutions-os",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "description": "One sign-in, one company switcher, one app grid. What every AutoSolutions app imports instead of copying.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",