@aindy/ui-kit 1.0.4 → 1.0.6
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/README.md +129 -0
- package/dist/api/_routes.d.ts +14 -4
- package/dist/api/auth.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +698 -660
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# @aindy/ui-kit
|
|
2
|
+
|
|
3
|
+
Shared UI components, React contexts, and API core for **AINDY platform** frontends.
|
|
4
|
+
|
|
5
|
+
`@aindy/ui-kit` is the client-side counterpart to the [`aindy-runtime`](https://pypi.org/project/aindy-runtime/)
|
|
6
|
+
backend: it centralizes the authenticated HTTP layer, the canonical backend route table,
|
|
7
|
+
auth/session contexts, and a small set of shared components and UI primitives so every
|
|
8
|
+
frontend built on the runtime talks to it the same way. It is published to npm and consumed
|
|
9
|
+
as a compiled bundle (`dist/` is built at publish time, not committed).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @aindy/ui-kit
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Peer dependencies** (provided by the host app):
|
|
18
|
+
|
|
19
|
+
- `react` ^19
|
|
20
|
+
- `react-dom` ^19
|
|
21
|
+
- `react-router-dom` ^6
|
|
22
|
+
|
|
23
|
+
## What it exports
|
|
24
|
+
|
|
25
|
+
### API core (`./api/_core.js`)
|
|
26
|
+
|
|
27
|
+
The authenticated request layer against the runtime. `buildApiUrl` prepends `API_BASE` to a
|
|
28
|
+
`ROUTES` value; the `request` family attaches the stored token and returns the parsed body.
|
|
29
|
+
|
|
30
|
+
| Export | Purpose |
|
|
31
|
+
|---|---|
|
|
32
|
+
| `request`, `authRequest`, `adminRequest`, `taggedRequest`, `requestAbsolute` | HTTP calls (auth-scoped / admin-scoped / cache-tagged / absolute-URL variants) |
|
|
33
|
+
| `buildApiUrl` | Resolve a `ROUTES` value against `API_BASE` |
|
|
34
|
+
| `getStoredToken`, `setStoredToken`, `clearStoredToken` | JWT storage |
|
|
35
|
+
| `unwrapEnvelope` | Unwrap the runtime's `{ data: … }` response envelope |
|
|
36
|
+
| `ApiError` | Typed error carrying status + body |
|
|
37
|
+
| `API_BASE` | Build-time API base (`VITE_API_BASE_URL`, default `""` — relative to origin) |
|
|
38
|
+
|
|
39
|
+
### Routes (`./api/_routes.js`)
|
|
40
|
+
|
|
41
|
+
- `ROUTES` — the canonical backend route table. **Every runtime/platform route carries the
|
|
42
|
+
full `/platform` prefix** (e.g. `ROUTES.OPERATOR.FLOW_STRATEGIES` → `/platform/flows/strategies`).
|
|
43
|
+
A value that drops the prefix segment 404s.
|
|
44
|
+
- `FEATURE_FLAGS` — NavLink gates for routes that are conditionally served; flip a flag to
|
|
45
|
+
`true` when its backing runtime route lands.
|
|
46
|
+
|
|
47
|
+
> **Runtime routes vs app routes.** `ROUTES` should carry **runtime/platform** paths only —
|
|
48
|
+
> these are shared by every consumer, and the runtime's authoritative list lives in
|
|
49
|
+
> [`aindy-runtime` `docs/runtime/UI_CONTRACT.md`](https://github.com/Masterplanner25/aindy-runtime/blob/main/docs/runtime/UI_CONTRACT.md).
|
|
50
|
+
> **App-domain** paths (e.g. `/compute/*` analytics, `/seo/*`) are **not** runtime routes and
|
|
51
|
+
> must not be baked into this shared kit; a consuming app owns those in its own route map that
|
|
52
|
+
> spreads and extends `ROUTES` (mirroring the backend's runtime/app split).
|
|
53
|
+
|
|
54
|
+
### Auth (`./api/auth.js`)
|
|
55
|
+
|
|
56
|
+
`bootIdentity`, `loginUser`, `registerUser`.
|
|
57
|
+
|
|
58
|
+
> **Invariant:** all three must `.then(unwrapEnvelope)` — `bootIdentity` populates
|
|
59
|
+
> `system.runtime.boot_mode` (read by the post-login redirect); returning the raw envelope
|
|
60
|
+
> silently breaks it.
|
|
61
|
+
|
|
62
|
+
### Contexts
|
|
63
|
+
|
|
64
|
+
- `AuthProvider` / `useAuth` — session + identity.
|
|
65
|
+
- `SystemProvider` / `useSystem` — runtime system state (incl. `boot_mode`).
|
|
66
|
+
|
|
67
|
+
### Components
|
|
68
|
+
|
|
69
|
+
`AppShell`, `ProtectedRoute`, `VersionMismatchBanner`, `Toast`, `LoadingPanel`,
|
|
70
|
+
`DomainError`, `AdminAccessRequired` (+ `useAdminApiGuard`), `EmptyState`.
|
|
71
|
+
|
|
72
|
+
### UI primitives
|
|
73
|
+
|
|
74
|
+
`Button` (+ `buttonVariants`), the `Card` family (`Card`, `CardHeader`, `CardTitle`,
|
|
75
|
+
`CardDescription`, `CardContent`, `CardFooter`), the `Tooltip` family (`Tooltip`,
|
|
76
|
+
`TooltipTrigger`, `TooltipContent`, `TooltipProvider`).
|
|
77
|
+
|
|
78
|
+
### Utilities
|
|
79
|
+
|
|
80
|
+
`cn` (class merge), `APPROVAL_EVENT`, `useApiCall`, `useToast`, `safeArray`, `safeMap`.
|
|
81
|
+
|
|
82
|
+
## Usage
|
|
83
|
+
|
|
84
|
+
```jsx
|
|
85
|
+
import {
|
|
86
|
+
AuthProvider, SystemProvider, ProtectedRoute, AppShell,
|
|
87
|
+
ROUTES, request, unwrapEnvelope,
|
|
88
|
+
} from "@aindy/ui-kit";
|
|
89
|
+
|
|
90
|
+
function App() {
|
|
91
|
+
return (
|
|
92
|
+
<AuthProvider>
|
|
93
|
+
<SystemProvider>
|
|
94
|
+
<AppShell>{/* routes */}</AppShell>
|
|
95
|
+
</SystemProvider>
|
|
96
|
+
</AuthProvider>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// A backend call through the canonical route table:
|
|
101
|
+
const strategies = await request(ROUTES.OPERATOR.FLOW_STRATEGIES).then(unwrapEnvelope);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Development
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm run build # vite build → dist/ (index.js, index.cjs, index.d.ts)
|
|
108
|
+
npm run lint # eslint src
|
|
109
|
+
npm test # vitest
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Versioning & the runtime
|
|
113
|
+
|
|
114
|
+
`@aindy/ui-kit` and `aindy-runtime` are **independently versioned**. This package *consumes*
|
|
115
|
+
the runtime's HTTP contract; the runtime does not depend on it. A ui-kit release does **not**
|
|
116
|
+
require a runtime release (and vice versa) — a runtime bump is only relevant when a ui-kit
|
|
117
|
+
change depends on a *new* runtime route or behavior. Keep `ROUTES` in sync with the runtime's
|
|
118
|
+
`docs/runtime/UI_CONTRACT.md`; a route that drifts from a served backend path is the
|
|
119
|
+
`UIKIT-ROUTE-DRIFT-1` failure mode.
|
|
120
|
+
|
|
121
|
+
## Publishing
|
|
122
|
+
|
|
123
|
+
`dist/` is gitignored and built fresh at publish:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npm version patch # e.g. 1.0.5 → 1.0.6
|
|
127
|
+
npm run build
|
|
128
|
+
npm publish
|
|
129
|
+
```
|
package/dist/api/_routes.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
export const FEATURE_FLAGS: Readonly<{
|
|
2
|
+
OPERATOR_FLOW_STRATEGIES: true;
|
|
3
|
+
OPERATOR_AUTOMATION_LOGS: false;
|
|
4
|
+
OPERATOR_SCHEDULER_STATUS: false;
|
|
5
|
+
RIPPLETRACE_VIEWER: false;
|
|
6
|
+
}>;
|
|
1
7
|
export const ROUTES: Readonly<{
|
|
2
8
|
AUTH: Readonly<{
|
|
3
9
|
LOGIN: "/auth/login";
|
|
4
10
|
REGISTER: "/auth/register";
|
|
11
|
+
LOGOUT: "/auth/logout";
|
|
5
12
|
}>;
|
|
6
13
|
TASKS: Readonly<{
|
|
7
14
|
LIST: "/tasks/list";
|
|
@@ -23,6 +30,8 @@ export const ROUTES: Readonly<{
|
|
|
23
30
|
RUN: (runId: any) => string;
|
|
24
31
|
APPROVE: (runId: any) => string;
|
|
25
32
|
REJECT: (runId: any) => string;
|
|
33
|
+
RECOVER: (runId: any) => string;
|
|
34
|
+
REPLAY: (runId: any) => string;
|
|
26
35
|
STEPS: (runId: any) => string;
|
|
27
36
|
EVENTS: (runId: any) => string;
|
|
28
37
|
TOOLS: "/apps/agent/tools";
|
|
@@ -142,14 +151,15 @@ export const ROUTES: Readonly<{
|
|
|
142
151
|
FLOW_RUN_RESUME: (runId: any) => string;
|
|
143
152
|
FLOW_REGISTRY: "/platform/flows/registry";
|
|
144
153
|
FLOW_STRATEGIES: "/platform/flows/strategies";
|
|
145
|
-
|
|
146
|
-
AUTOMATION_LOG: (logId: any) => string;
|
|
147
|
-
AUTOMATION_REPLAY: (logId: any) => string;
|
|
148
|
-
SCHEDULER_STATUS: "/platform/observability/scheduler/status";
|
|
154
|
+
RIPPLETRACE_STATUS: "/platform/observability/rippletrace/status";
|
|
149
155
|
OBSERVABILITY_REQUESTS: "/platform/observability/requests";
|
|
150
156
|
OBSERVABILITY_DASHBOARD: "/platform/observability/dashboard";
|
|
151
157
|
CLIENT_ERROR: "/client/error";
|
|
152
158
|
CLIENT_VITALS: "/client/vitals";
|
|
159
|
+
AUTOMATION_LOGS: "/automation/logs";
|
|
160
|
+
AUTOMATION_LOG: (logId: any) => string;
|
|
161
|
+
AUTOMATION_REPLAY: (logId: any) => string;
|
|
162
|
+
SCHEDULER_STATUS: "/platform/observability/scheduler/status";
|
|
153
163
|
}>;
|
|
154
164
|
PLATFORM: Readonly<{
|
|
155
165
|
DASHBOARD_OVERVIEW: "/dashboard/overview";
|
package/dist/api/auth.d.ts
CHANGED