autosolutions-os 0.1.0 → 0.2.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 +104 -0
- package/README.md +135 -0
- package/dist/chrome.d.ts +18 -0
- package/dist/chrome.js +39 -15
- package/dist/client.js +2 -2
- package/dist/context.d.ts +7 -5
- package/dist/context.js +22 -17
- package/dist/frame.d.ts +83 -0
- package/dist/frame.js +105 -0
- package/dist/gate.js +2 -2
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -7
- package/dist/nav.d.ts +244 -0
- package/dist/nav.js +453 -0
- package/dist/server.js +2 -2
- package/dist/session.js +1 -1
- package/dist/url.d.ts +9 -0
- package/dist/url.js +20 -0
- package/package.json +8 -3
package/dist/gate.js
CHANGED
|
@@ -13,8 +13,8 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
13
13
|
* lists, reads to the user as "the product is broken".
|
|
14
14
|
*/
|
|
15
15
|
import { useCallback, useEffect, useState } from "react";
|
|
16
|
-
import { isActiveMember, isEntitled } from "./identity";
|
|
17
|
-
import { invalidateOsContext, loadOsContext } from "./context";
|
|
16
|
+
import { isActiveMember, isEntitled } from "./identity.js";
|
|
17
|
+
import { invalidateOsContext, loadOsContext } from "./context.js";
|
|
18
18
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
19
19
|
/** The session is restored from storage asynchronously; give it one beat. */
|
|
20
20
|
const RESTORE_GRACE_MS = 1500;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { coreUrl, corePublishableKey, coreProjectRef, companyMarkUrl, appLabelUrl, HUB_URL, PARENT_DOMAIN } from "./config";
|
|
2
|
-
export { createOsClient, resetOsClient, type OsClient } from "./client";
|
|
3
|
-
export { adoptSharedSession, publishSessionChanges, sharedSessionCookieName, joinChunks } from "./session";
|
|
4
|
-
export { loadOsContext, invalidateOsContext, useOsContext, useTenant, useApps, groupApps, markFor, labelFor, withTenantHint, type OsContext, type OsTenant, type OsApp, } from "./context";
|
|
5
|
-
export { isEntitled, isActiveMember, appRole, appVariant, currentTenant, toolAllowed, myAdminScope, canManageCurrentCompany, type AdminScope, } from "./identity";
|
|
6
|
-
export { OsAppSwitcher, OsAppSwitcherPlate, OsCompanySwitcher, OsBar } from "./chrome";
|
|
7
|
-
export { OsAuthGate, type OsAuthGateProps } from "./gate";
|
|
1
|
+
export { coreUrl, corePublishableKey, coreProjectRef, companyMarkUrl, appLabelUrl, HUB_URL, PARENT_DOMAIN } from "./config.js";
|
|
2
|
+
export { createOsClient, resetOsClient, type OsClient } from "./client.js";
|
|
3
|
+
export { adoptSharedSession, publishSessionChanges, sharedSessionCookieName, joinChunks } from "./session.js";
|
|
4
|
+
export { loadOsContext, invalidateOsContext, refreshOsContext, useOsContext, useTenant, useApps, groupApps, markFor, labelFor, withTenantHint, type OsContext, type OsTenant, type OsApp, } from "./context.js";
|
|
5
|
+
export { isEntitled, isActiveMember, appRole, appVariant, currentTenant, toolAllowed, myAdminScope, canManageCurrentCompany, type AdminScope, } from "./identity.js";
|
|
6
|
+
export { OsAppSwitcher, OsAppSwitcherPlate, OsCompanySwitcher, OsBar, useCompanySwitch } from "./chrome.js";
|
|
7
|
+
export { OsAuthGate, type OsAuthGateProps } from "./gate.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { coreUrl, corePublishableKey, coreProjectRef, companyMarkUrl, appLabelUrl, HUB_URL, PARENT_DOMAIN } from "./config";
|
|
2
|
-
export { createOsClient, resetOsClient } from "./client";
|
|
3
|
-
export { adoptSharedSession, publishSessionChanges, sharedSessionCookieName, joinChunks } from "./session";
|
|
4
|
-
export { loadOsContext, invalidateOsContext, useOsContext, useTenant, useApps, groupApps, markFor, labelFor, withTenantHint, } from "./context";
|
|
5
|
-
export { isEntitled, isActiveMember, appRole, appVariant, currentTenant, toolAllowed, myAdminScope, canManageCurrentCompany, } from "./identity";
|
|
6
|
-
export { OsAppSwitcher, OsAppSwitcherPlate, OsCompanySwitcher, OsBar } from "./chrome";
|
|
7
|
-
export { OsAuthGate } from "./gate";
|
|
1
|
+
export { coreUrl, corePublishableKey, coreProjectRef, companyMarkUrl, appLabelUrl, HUB_URL, PARENT_DOMAIN } from "./config.js";
|
|
2
|
+
export { createOsClient, resetOsClient } from "./client.js";
|
|
3
|
+
export { adoptSharedSession, publishSessionChanges, sharedSessionCookieName, joinChunks } from "./session.js";
|
|
4
|
+
export { loadOsContext, invalidateOsContext, refreshOsContext, useOsContext, useTenant, useApps, groupApps, markFor, labelFor, withTenantHint, } from "./context.js";
|
|
5
|
+
export { isEntitled, isActiveMember, appRole, appVariant, currentTenant, toolAllowed, myAdminScope, canManageCurrentCompany, } from "./identity.js";
|
|
6
|
+
export { OsAppSwitcher, OsAppSwitcherPlate, OsCompanySwitcher, OsBar, useCompanySwitch } from "./chrome.js";
|
|
7
|
+
export { OsAuthGate } from "./gate.js";
|
package/dist/nav.d.ts
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The OS menu: the rail every app shows, the 53 tools of the menu map by
|
|
3
|
+
* function, and the one set of routing rules that turns a location into a
|
|
4
|
+
* place in the workspace frame and a click into a destination.
|
|
5
|
+
*
|
|
6
|
+
* Three levels, the same in every AutoSolutions webapp:
|
|
7
|
+
* 1 the rail Hub, Finance, Marketing, Commercial, Operations
|
|
8
|
+
* 2 the menu that function's tools, grouped Reporting / Planning
|
|
9
|
+
* 3 the tab menu the open tool's views, with Back to hub
|
|
10
|
+
*
|
|
11
|
+
* Pure data and pure functions: no React, no Supabase. An app that is not on
|
|
12
|
+
* the core imports this beside the design system's WorkspaceFrame; an app on
|
|
13
|
+
* the core gets it through OsWorkspaceFrame (`autosolutions-os/frame`).
|
|
14
|
+
*/
|
|
15
|
+
import { HUB_URL } from "./config.js";
|
|
16
|
+
export { HUB_URL };
|
|
17
|
+
/** A rail or menu row, shaped to drop into the design system's WorkspaceFrame. */
|
|
18
|
+
export type OsNavItem = {
|
|
19
|
+
id: string;
|
|
20
|
+
label: string;
|
|
21
|
+
icon?: string;
|
|
22
|
+
/** Visible but locked; say why in `title`. */
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
title?: string;
|
|
25
|
+
/** A count at the end of the row, such as unread replies. */
|
|
26
|
+
badge?: string | number;
|
|
27
|
+
};
|
|
28
|
+
export type OsToolStatus = "Live" | "In progress" | "To build" | "No status";
|
|
29
|
+
export type OsTool = {
|
|
30
|
+
id: string;
|
|
31
|
+
label: string;
|
|
32
|
+
icon: string;
|
|
33
|
+
status: OsToolStatus;
|
|
34
|
+
};
|
|
35
|
+
export type OsToolGroup = {
|
|
36
|
+
title: string;
|
|
37
|
+
items: OsTool[];
|
|
38
|
+
};
|
|
39
|
+
export type OsMenuFunction = "finance" | "marketing" | "commercial" | "operations";
|
|
40
|
+
/** The rail: the Hub, then the four business functions. */
|
|
41
|
+
export declare const OS_FUNCTIONS: OsNavItem[];
|
|
42
|
+
/**
|
|
43
|
+
* "Menu map - all 49 items by function", as the design handoff carries it,
|
|
44
|
+
* plus four Live apps the sheet did not have: Shelf simulator (Marketing >
|
|
45
|
+
* Planning), Key accounts (Commercial > Planning), PM Copilot and Candidate
|
|
46
|
+
* hub (Operations > Planning). Owner, source and cadence stay in the sheet.
|
|
47
|
+
* Icons are glyph ids from the design system's NAV_ICONS, which draws them
|
|
48
|
+
* inline; the four new rows borrow ops-inventory-value (a stocked shelf),
|
|
49
|
+
* com-customer-scorecard, hub-tasks and hub-accounts.
|
|
50
|
+
*/
|
|
51
|
+
export declare const OS_MENU: Record<OsMenuFunction, OsToolGroup[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Where a Live tool lives. `app` is its catalogue key: in a frame backed by
|
|
54
|
+
* the catalogue (OsWorkspaceFrame), the tool links to that app's address from
|
|
55
|
+
* os_context(), with the company as ?tenant=, only when the person holds the
|
|
56
|
+
* app, and is locked when they do not. `url` is a fixed address, used only by
|
|
57
|
+
* staticLinks(): a frame off the core, with no catalogue to ask. `path` is a
|
|
58
|
+
* route inside the app, query included, joined to either address.
|
|
59
|
+
*/
|
|
60
|
+
export type OsToolLink = {
|
|
61
|
+
app?: string;
|
|
62
|
+
path?: string;
|
|
63
|
+
url?: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Where the tools go: every Live tool, and the tools whose app is already in
|
|
67
|
+
* the catalogue whatever the map says of them (Influencer Manager, Marketing
|
|
68
|
+
* calendar, Paid media), so every app the app switcher offers is reachable
|
|
69
|
+
* from the menu too. Every link opens in the same tab. Pricing researcher and
|
|
70
|
+
* Brand voice copywriter have no app to open yet, so they stay unlinked
|
|
71
|
+
* ("Live, not linked from the Hub yet"). The Hub itself (smart_comms_hub) is
|
|
72
|
+
* the rail's Hub, not a row.
|
|
73
|
+
*/
|
|
74
|
+
export declare const OS_TOOL_LINKS: Record<string, OsToolLink>;
|
|
75
|
+
/** The Hub's own pages, for the rail's Hub, Admin and Settings rows in other apps. */
|
|
76
|
+
export declare const HUB_PATHS: {
|
|
77
|
+
readonly home: "/comms/overview";
|
|
78
|
+
readonly admin: "/admin";
|
|
79
|
+
readonly settings: "/comms/settings";
|
|
80
|
+
};
|
|
81
|
+
/** Why a row is locked. A tool whose status is In progress or To build says so instead. */
|
|
82
|
+
export declare const HINTS: {
|
|
83
|
+
readonly locked: "Ask your company admin to switch this on for you";
|
|
84
|
+
readonly notBuilt: "Not built yet";
|
|
85
|
+
readonly notLinked: "Live, not linked from the Hub yet";
|
|
86
|
+
};
|
|
87
|
+
/** The rail footer: Admin (for someone who manages something), Settings, then Sign out, always last. */
|
|
88
|
+
export declare function osFooter({ admin }?: {
|
|
89
|
+
admin?: boolean;
|
|
90
|
+
}): OsNavItem[];
|
|
91
|
+
/**
|
|
92
|
+
* Tool id to address, for the tools with a fixed `url`: what a frame off the
|
|
93
|
+
* core, which has no catalogue to ask, can link to. No tenant hint.
|
|
94
|
+
*/
|
|
95
|
+
export declare function staticLinks(): Record<string, string>;
|
|
96
|
+
/**
|
|
97
|
+
* Tool id to address, and tool id to the reason a row is off, for
|
|
98
|
+
* OsWorkspaceFrame to pass to osFrame. `apps` is os_context().apps: the apps
|
|
99
|
+
* this person holds in the acting company, as the app switcher lists them.
|
|
100
|
+
* For a tool whose OS_TOOL_LINKS entry names an app:
|
|
101
|
+
* - held, with an address: linked to it (plus `path`), with the company as
|
|
102
|
+
* ?tenant=, whatever status the map gives the tool, because the switcher
|
|
103
|
+
* already offers that app;
|
|
104
|
+
* - held, not deployed yet (no address): a Live tool reads "Live, not linked
|
|
105
|
+
* from the Hub yet"; any other keeps the map's own status;
|
|
106
|
+
* - not held: a Live tool is locked ("Ask your company admin to switch this
|
|
107
|
+
* on for you"); any other keeps the map's own status (Not built yet, In
|
|
108
|
+
* progress, To build).
|
|
109
|
+
* A fixed `url` is never consulted here: it is no way round the catalogue.
|
|
110
|
+
* Tools with no app keep osFrame's own rules. Links are final: osFrame adds
|
|
111
|
+
* nothing to them.
|
|
112
|
+
*/
|
|
113
|
+
export declare function catalogueLinks(apps: ReadonlyArray<{
|
|
114
|
+
key: string;
|
|
115
|
+
url: string | null;
|
|
116
|
+
}>, tenantSlug?: string | null): {
|
|
117
|
+
links: Record<string, string>;
|
|
118
|
+
locked: Record<string, string>;
|
|
119
|
+
};
|
|
120
|
+
/** A route inside this app. `path` may carry a query, e.g. "/launcher?section=signature". */
|
|
121
|
+
export type OsRoute = {
|
|
122
|
+
/** Where a click goes. */
|
|
123
|
+
path: string;
|
|
124
|
+
/** More path prefixes that select the row, e.g. "/comms" for a tool whose path is "/comms/overview". */
|
|
125
|
+
match?: string[];
|
|
126
|
+
};
|
|
127
|
+
export type OsTab = OsNavItem & OsRoute;
|
|
128
|
+
/** Titled tabs, drawn with the second menu's section headings. */
|
|
129
|
+
export type OsTabGroup = {
|
|
130
|
+
title?: string;
|
|
131
|
+
items: OsTab[];
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* One of this app's own tools. `id` is an OS_MENU tool id, which places it in
|
|
135
|
+
* the menu and enables it however the map marks it; an id the map does not
|
|
136
|
+
* have needs `fn`, `section`, `label` and `icon` to be placed.
|
|
137
|
+
*/
|
|
138
|
+
export type OsAppTool = OsRoute & {
|
|
139
|
+
id: string;
|
|
140
|
+
/**
|
|
141
|
+
* The third menu, flat or in titled groups. Tabs with a `path` navigate;
|
|
142
|
+
* tabs without are page state, read from the frame's state.
|
|
143
|
+
*/
|
|
144
|
+
tabs?: OsTab[] | OsTabGroup[];
|
|
145
|
+
/** false for a tool that carries its own tab row in the page: opening it closes the menu. */
|
|
146
|
+
menu?: boolean;
|
|
147
|
+
/** A count at the end of the row, such as unread replies. */
|
|
148
|
+
badge?: string | number;
|
|
149
|
+
fn?: string;
|
|
150
|
+
section?: string;
|
|
151
|
+
label?: string;
|
|
152
|
+
icon?: string;
|
|
153
|
+
};
|
|
154
|
+
/** A row in the Hub function's menu. The Hub passes its own; other apps pass none. */
|
|
155
|
+
export type OsHubItem = OsNavItem & Partial<OsRoute> & {
|
|
156
|
+
href?: string;
|
|
157
|
+
tabs?: OsTab[] | OsTabGroup[];
|
|
158
|
+
menu?: boolean;
|
|
159
|
+
};
|
|
160
|
+
export type OsHubSection = {
|
|
161
|
+
title?: string;
|
|
162
|
+
items: OsHubItem[];
|
|
163
|
+
};
|
|
164
|
+
/** A menu row as osFrame hands it to WorkspaceFrame. */
|
|
165
|
+
export type OsMenuRow = OsNavItem & {
|
|
166
|
+
path?: string;
|
|
167
|
+
match?: string[];
|
|
168
|
+
href?: string;
|
|
169
|
+
tabs?: OsTab[] | OsTabGroup[];
|
|
170
|
+
menu?: boolean;
|
|
171
|
+
};
|
|
172
|
+
export type OsMenuSection = {
|
|
173
|
+
title?: string;
|
|
174
|
+
items: OsMenuRow[];
|
|
175
|
+
};
|
|
176
|
+
/** Where the frame is. `open` omitted means the frame's own rule. */
|
|
177
|
+
export type OsLocation = {
|
|
178
|
+
fn: string;
|
|
179
|
+
item: string | null;
|
|
180
|
+
tab: string | null;
|
|
181
|
+
open?: boolean;
|
|
182
|
+
};
|
|
183
|
+
/** Where a click goes: inside this app (the router navigates) or to another app. */
|
|
184
|
+
export type OsTarget = {
|
|
185
|
+
href: string;
|
|
186
|
+
external: boolean;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* The part of WorkspaceFrame's state a destination depends on. `reselect` is
|
|
190
|
+
* WorkspaceFrame's flag for a click on what it already shows.
|
|
191
|
+
*/
|
|
192
|
+
export type OsFrameState = {
|
|
193
|
+
fn: {
|
|
194
|
+
id: string;
|
|
195
|
+
};
|
|
196
|
+
item: {
|
|
197
|
+
id: string;
|
|
198
|
+
} | null;
|
|
199
|
+
tab: {
|
|
200
|
+
id: string;
|
|
201
|
+
} | null;
|
|
202
|
+
reselect?: boolean | undefined;
|
|
203
|
+
};
|
|
204
|
+
export type OsFrameOptions = {
|
|
205
|
+
/** This app's catalogue key; "hub" for the Hub itself. */
|
|
206
|
+
appKey: string;
|
|
207
|
+
tools?: OsAppTool[];
|
|
208
|
+
hubItems?: OsHubSection[];
|
|
209
|
+
/** Tool id to address, for tools served by other apps (catalogueLinks or staticLinks). Used as given. */
|
|
210
|
+
links?: Record<string, string>;
|
|
211
|
+
/** Tool id to the reason its row is off (catalogueLinks): wins over the map's status. */
|
|
212
|
+
locked?: Record<string, string>;
|
|
213
|
+
/** Show Admin in the footer. */
|
|
214
|
+
admin?: boolean;
|
|
215
|
+
/** This app's settings route. The rail marks Settings there. Default: the Hub's settings. */
|
|
216
|
+
settingsPath?: string;
|
|
217
|
+
/** This app's landing. In the Hub it is also where Back to hub lands. Default "/", or the Hub's home in the Hub. */
|
|
218
|
+
homePath?: string;
|
|
219
|
+
/** Default HUB_URL. */
|
|
220
|
+
hubUrl?: string;
|
|
221
|
+
/** The acting company's slug, carried to the Hub as ?tenant=. (catalogueLinks carries it to other apps.) */
|
|
222
|
+
tenantSlug?: string | null;
|
|
223
|
+
};
|
|
224
|
+
export type OsFrame = {
|
|
225
|
+
functions: OsNavItem[];
|
|
226
|
+
sections: Record<string, OsMenuSection[]>;
|
|
227
|
+
footerItems: OsNavItem[];
|
|
228
|
+
homeFunction: "hub";
|
|
229
|
+
/** Where a location (pathname plus query) sits in the frame. */
|
|
230
|
+
locate: (location: string) => OsLocation;
|
|
231
|
+
/**
|
|
232
|
+
* Where a click from `location` goes; null when it goes nowhere (opening a
|
|
233
|
+
* menu, a locked row, or already there). A reselect (`state.reselect`, a
|
|
234
|
+
* click on the tab or row the frame already shows) goes to that tab's or
|
|
235
|
+
* row's own path unless `location` is exactly it, so a page filed under a
|
|
236
|
+
* tab (a draft under Requests) goes back to the tab's page.
|
|
237
|
+
*/
|
|
238
|
+
targetFor: (state: OsFrameState, location: string) => OsTarget | null;
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* The frame for one app: the rail, every function's menu for this person and
|
|
242
|
+
* company, the footer, and the only routing logic the frame needs.
|
|
243
|
+
*/
|
|
244
|
+
export declare function osFrame(options: OsFrameOptions): OsFrame;
|