@tristan2828/ui-foundation 4.106.0 → 4.107.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.
- package/conventions/docs/add-an-entity.md +65 -24
- package/dist/api/contracts.d.ts +8 -1
- package/dist/api/gateway/environment.js +9 -1
- package/dist/api/gateway/errors.d.ts +7 -0
- package/dist/api/gateway/errors.js +32 -0
- package/dist/api/transport/index.d.ts +10 -0
- package/dist/api/transport/index.js +45 -3
- package/dist/components/app/error-state.js +12 -2
- package/dist/components/app/module-card.js +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/gateway.d.ts +1 -1
- package/dist/gateway.js +1 -1
- package/package.json +1 -1
|
@@ -3,29 +3,30 @@
|
|
|
3
3
|
<!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
|
|
4
4
|
## Index
|
|
5
5
|
|
|
6
|
-
- [The reference files](#the-reference-files) · lines
|
|
7
|
-
- [Before anything: the entity plan](#before-anything-the-entity-plan) · lines
|
|
8
|
-
- Step 1: Add `<Entity>` to `openapi.yaml` · lines
|
|
9
|
-
- Step 2: `npm run gen:api` · lines
|
|
10
|
-
- Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines
|
|
11
|
-
- Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines
|
|
12
|
-
- Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines
|
|
13
|
-
- Step 6: Copy the reference files, one for one, not just the two screens · lines
|
|
14
|
-
- Step 7: Register routes · lines
|
|
15
|
-
- Step 8: Add Playwright specs for all three screens · lines
|
|
16
|
-
- Step 9: Register the nav entry and route names · lines
|
|
17
|
-
- Step 10: `npm run verify`. · lines
|
|
18
|
-
- [How a list opens a record](#how-a-list-opens-a-record) · lines
|
|
19
|
-
- [The record view](#the-record-view) · lines
|
|
20
|
-
- [Forms](#forms) · lines
|
|
21
|
-
- [Dialogs](#dialogs) · lines
|
|
22
|
-
- [Toasts and feedback](#toasts-and-feedback) · lines
|
|
23
|
-
- [What not to copy](#what-not-to-copy) · lines
|
|
24
|
-
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines
|
|
25
|
-
- [Deleting](#deleting) · lines
|
|
26
|
-
- [Fields only a script writes](#fields-only-a-script-writes) · lines
|
|
27
|
-
- [Searching one part of the app](#searching-one-part-of-the-app) · lines
|
|
28
|
-
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines
|
|
6
|
+
- [The reference files](#the-reference-files) · lines 45–67
|
|
7
|
+
- [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 69–850
|
|
8
|
+
- Step 1: Add `<Entity>` to `openapi.yaml` · lines 111–118
|
|
9
|
+
- Step 2: `npm run gen:api` · lines 119–120
|
|
10
|
+
- Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines 121–132
|
|
11
|
+
- Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines 133–142
|
|
12
|
+
- Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines 143–149
|
|
13
|
+
- Step 6: Copy the reference files, one for one, not just the two screens · lines 150–738
|
|
14
|
+
- Step 7: Register routes · lines 739–754
|
|
15
|
+
- Step 8: Add Playwright specs for all three screens · lines 755–832
|
|
16
|
+
- Step 9: Register the nav entry and route names · lines 833–847
|
|
17
|
+
- Step 10: `npm run verify`. · lines 848–850
|
|
18
|
+
- [How a list opens a record](#how-a-list-opens-a-record) · lines 852–1249
|
|
19
|
+
- [The record view](#the-record-view) · lines 1005–1099
|
|
20
|
+
- [Forms](#forms) · lines 1101–1166
|
|
21
|
+
- [Dialogs](#dialogs) · lines 1168–1199
|
|
22
|
+
- [Toasts and feedback](#toasts-and-feedback) · lines 1201–1249
|
|
23
|
+
- [What not to copy](#what-not-to-copy) · lines 1251–1283
|
|
24
|
+
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1285–1302
|
|
25
|
+
- [Deleting](#deleting) · lines 1304–1335
|
|
26
|
+
- [Fields only a script writes](#fields-only-a-script-writes) · lines 1337–1358
|
|
27
|
+
- [Searching one part of the app](#searching-one-part-of-the-app) · lines 1360–1369
|
|
28
|
+
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1372–1414
|
|
29
|
+
- [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1416–1452
|
|
29
30
|
|
|
30
31
|
<!-- /index -->
|
|
31
32
|
|
|
@@ -143,7 +144,9 @@ is a filled-in example while the Widgets demo is still here).
|
|
|
143
144
|
tests pass, built on `safeFetch`/`toAppError` from
|
|
144
145
|
`@tristan2828/ui-foundation/gateway` (see `src/api/gateway/widgets.ts`).
|
|
145
146
|
Wire → `Page<T>` / `AppError` translation only; no hand-written types
|
|
146
|
-
(everything comes from `schema.d.ts`).
|
|
147
|
+
(everything comes from `schema.d.ts`). A proxy's sign-in page or redirect never
|
|
148
|
+
reaches it: `safeFetch` throws kind `proxy_auth` first
|
|
149
|
+
([Behind a sign-in proxy](#behind-a-sign-in-proxy)).
|
|
147
150
|
6. **Copy the reference files, one for one, not just the two screens**
|
|
148
151
|
(the Widgets demo's, or the ones the app's `### Reference files` names) — shaped by the plan: table columns and sortable columns from
|
|
149
152
|
its "List" column, toolbar filters from its "Filter" column, form fields
|
|
@@ -1409,3 +1412,41 @@ def note(caller, tool, arguments, entities):
|
|
|
1409
1412
|
register_entities(ENTITIES, instructions="Amounts are in the account's currency.")
|
|
1410
1413
|
register_answer_note(note)
|
|
1411
1414
|
```
|
|
1415
|
+
|
|
1416
|
+
## Behind a sign-in proxy
|
|
1417
|
+
|
|
1418
|
+
An app put behind an identity-aware proxy that has its own sign-in
|
|
1419
|
+
(Cloudflare Access is the usual one; an OAuth proxy or a VPN gateway's
|
|
1420
|
+
portal works the same way) can outlive that sign-in: the page stays open,
|
|
1421
|
+
the proxy's session lapses, and the next request gets the proxy's answer
|
|
1422
|
+
instead of the app's. The foundation handles it (4.107), with nothing for
|
|
1423
|
+
the app to write:
|
|
1424
|
+
|
|
1425
|
+
- **The request asks for JSON as a script.** `safeFetch` sends
|
|
1426
|
+
`Accept: application/json` and `X-Requested-With: XMLHttpRequest`
|
|
1427
|
+
(unless the gateway module set its own) and doesn't follow redirects
|
|
1428
|
+
(`redirect: "manual"`, unless the module passes `"follow"`), so a proxy
|
|
1429
|
+
that can answers a script with a 401, and one that can't answers with a
|
|
1430
|
+
redirect the browser doesn't chase to another origin.
|
|
1431
|
+
- **The proxy's answer becomes one `AppError`, kind `proxy_auth`.**
|
|
1432
|
+
`safeFetch` throws it, before your gateway module sees the response,
|
|
1433
|
+
for: a page (`text/html`) on a 2xx, 401 or 403; a 401 or 403 whose body
|
|
1434
|
+
isn't JSON; a redirect not followed (an opaque redirect); and a redirect
|
|
1435
|
+
followed to another origin. A step 5 gateway module needs no change.
|
|
1436
|
+
The app's own answers are untouched: a JSON 401 is still `auth` (the
|
|
1437
|
+
app's session, which sends the person to `/login`), and a 404, 422, 429
|
|
1438
|
+
or 5xx, JSON or not, is what `toAppError` always made it.
|
|
1439
|
+
- **The screens say "Sign In Again".** `ErrorState` (every `DataTable`,
|
|
1440
|
+
`EntityView`, `WidgetCard`, `Board`, the shell's own session check) and
|
|
1441
|
+
`ModuleCard` show "Sign-in expired" with a **Sign In Again** button in
|
|
1442
|
+
place of any retry. It reloads the whole page, so the proxy's sign-in
|
|
1443
|
+
runs and brings the person back. A screen with its own error UI checks
|
|
1444
|
+
`error.kind === 'proxy_auth'` and offers the same reload.
|
|
1445
|
+
- **Your contract tests don't change.** `openapi.yaml` and the step 3
|
|
1446
|
+
gateway tests describe the app's own responses, never the proxy's; the
|
|
1447
|
+
proxy isn't part of the contract. `proxyAuthError()` (from
|
|
1448
|
+
`@tristan2828/ui-foundation/gateway`) is the error itself, for a mock or
|
|
1449
|
+
a test of a screen's state.
|
|
1450
|
+
- **On the proxy's side**, nothing is required. Where it offers a 401 for
|
|
1451
|
+
scripts instead of a redirect (Cloudflare Access does for requests with
|
|
1452
|
+
`X-Requested-With`), either answer works.
|
package/dist/api/contracts.d.ts
CHANGED
|
@@ -5,7 +5,14 @@ export type Page<T> = {
|
|
|
5
5
|
pageSize: number;
|
|
6
6
|
};
|
|
7
7
|
export type AppError = {
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* `proxy_auth`: the answer came from something in front of the app (an
|
|
10
|
+
* identity-aware proxy such as Cloudflare Access) whose own sign-in has
|
|
11
|
+
* lapsed, not from the app: a page or a redirect where JSON was
|
|
12
|
+
* expected. Only a full page load signs in again. Not the app's own
|
|
13
|
+
* session, which is `auth`.
|
|
14
|
+
*/
|
|
15
|
+
kind: "validation" | "notfound" | "auth" | "rate_limited" | "server" | "network" | "proxy_auth";
|
|
9
16
|
message: string;
|
|
10
17
|
fieldErrors?: Record<string, string[]>;
|
|
11
18
|
/**
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { safeFetch, toAppError } from "./errors.js";
|
|
2
2
|
export async function getDataLabel() {
|
|
3
|
-
|
|
3
|
+
let res;
|
|
4
|
+
try {
|
|
5
|
+
res = await safeFetch("/environment");
|
|
6
|
+
}
|
|
7
|
+
catch (error) {
|
|
8
|
+
if (error.kind === "proxy_auth")
|
|
9
|
+
return null;
|
|
10
|
+
throw error;
|
|
11
|
+
}
|
|
4
12
|
if (res.status === 404)
|
|
5
13
|
return null;
|
|
6
14
|
if (res.status !== 200)
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { type ApiResponse } from "../transport/index.js";
|
|
2
2
|
import type { AppError } from "../contracts.js";
|
|
3
3
|
export declare function safeFetch(path: string, init?: RequestInit): Promise<ApiResponse>;
|
|
4
|
+
/**
|
|
5
|
+
* The AppError for a lapsed sign-in at a proxy in front of the app (kind
|
|
6
|
+
* `proxy_auth`): only a full page load can sign in again, which
|
|
7
|
+
* `ErrorState` offers ("Sign In Again"). `safeFetch` throws it itself, so
|
|
8
|
+
* an app's gateway modules need no change to get it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function proxyAuthError(status?: number): AppError;
|
|
4
11
|
export declare function httpStatusOf(error: AppError): number | undefined;
|
|
5
12
|
export declare function toAppError(status: number, body: unknown, headers?: Headers): AppError;
|
|
6
13
|
export declare function networkError(): AppError;
|
|
@@ -18,8 +18,40 @@ export async function safeFetch(path, init) {
|
|
|
18
18
|
throw networkError();
|
|
19
19
|
}
|
|
20
20
|
reportAnswered();
|
|
21
|
+
if (isProxySignIn(response))
|
|
22
|
+
throw proxyAuthError(response.status);
|
|
21
23
|
return response;
|
|
22
24
|
}
|
|
25
|
+
// What a proxy in front of the app (an identity-aware proxy such as
|
|
26
|
+
// Cloudflare Access) sends once its own sign-in has lapsed, in place of
|
|
27
|
+
// the app's JSON: any redirect (never in an app's contract), or a page or
|
|
28
|
+
// unparseable body on a success, a 401 or a 403. The app's own 401 and
|
|
29
|
+
// 403 are always JSON (the foundation's error envelopes), so they still
|
|
30
|
+
// reach toAppError as before. Anything else not JSON (a load balancer's
|
|
31
|
+
// 502 page, say) is left to the caller's toAppError, as before.
|
|
32
|
+
function isProxySignIn(response) {
|
|
33
|
+
const { foreign, status } = response;
|
|
34
|
+
if (foreign === "opaque-redirect" || foreign === "cross-origin-redirect")
|
|
35
|
+
return true;
|
|
36
|
+
if (foreign === "html" && status >= 200 && status < 300)
|
|
37
|
+
return true;
|
|
38
|
+
return (foreign === "html" || foreign === "not-json") && (status === 401 || status === 403);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The AppError for a lapsed sign-in at a proxy in front of the app (kind
|
|
42
|
+
* `proxy_auth`): only a full page load can sign in again, which
|
|
43
|
+
* `ErrorState` offers ("Sign In Again"). `safeFetch` throws it itself, so
|
|
44
|
+
* an app's gateway modules need no change to get it.
|
|
45
|
+
*/
|
|
46
|
+
export function proxyAuthError(status) {
|
|
47
|
+
const error = {
|
|
48
|
+
kind: "proxy_auth",
|
|
49
|
+
message: "Your sign-in has expired. Reload the page to sign in again.",
|
|
50
|
+
};
|
|
51
|
+
if (status)
|
|
52
|
+
STATUS.set(error, status);
|
|
53
|
+
return error;
|
|
54
|
+
}
|
|
23
55
|
/**
|
|
24
56
|
* Pass the response's `headers` so a 429 carries its Retry-After
|
|
25
57
|
* (`retryAfterSeconds`); without them it's still `rate_limited`.
|
|
@@ -3,5 +3,15 @@ export type ApiResponse = {
|
|
|
3
3
|
body: unknown;
|
|
4
4
|
/** The response's headers (a 429's Retry-After, for one). */
|
|
5
5
|
headers: Headers;
|
|
6
|
+
/**
|
|
7
|
+
* Set when the answer can't be the app's own API speaking JSON, the way
|
|
8
|
+
* an identity-aware proxy in front of the app answers once its sign-in
|
|
9
|
+
* has lapsed: `html` (a page where JSON was expected), `not-json` (a
|
|
10
|
+
* body that doesn't parse as JSON), `cross-origin-redirect` (followed to
|
|
11
|
+
* another origin) or `opaque-redirect` (a redirect not followed). The
|
|
12
|
+
* gateway decides what it means (`safeFetch`). Absent on every ordinary
|
|
13
|
+
* response.
|
|
14
|
+
*/
|
|
15
|
+
foreign?: "html" | "not-json" | "cross-origin-redirect" | "opaque-redirect";
|
|
6
16
|
};
|
|
7
17
|
export declare function apiFetch(path: string, init?: RequestInit): Promise<ApiResponse>;
|
|
@@ -4,11 +4,53 @@
|
|
|
4
4
|
// Owns the base URL and the raw HTTP call; knows nothing about widgets,
|
|
5
5
|
// pagination, or error shapes — that translation is the gateway's job.
|
|
6
6
|
const BASE_URL = "/api";
|
|
7
|
+
// Sent unless the caller set them: they tell a proxy in front of the app
|
|
8
|
+
// that this is a script asking for JSON, not a page, so a proxy that can
|
|
9
|
+
// answers a lapsed sign-in with a 401 rather than a redirect to its login
|
|
10
|
+
// page (Cloudflare Access reads X-Requested-With; others read Accept).
|
|
11
|
+
const DEFAULT_HEADERS = [
|
|
12
|
+
["accept", "application/json"],
|
|
13
|
+
["x-requested-with", "XMLHttpRequest"],
|
|
14
|
+
];
|
|
7
15
|
export async function apiFetch(path, init) {
|
|
8
|
-
const
|
|
16
|
+
const headers = new Headers(init?.headers);
|
|
17
|
+
for (const [name, value] of DEFAULT_HEADERS)
|
|
18
|
+
if (!headers.has(name))
|
|
19
|
+
headers.set(name, value);
|
|
20
|
+
// A redirect is never part of the app's contract. A proxy's redirect to
|
|
21
|
+
// its login page on another origin, if followed, fails as a network
|
|
22
|
+
// error that can't be told from being offline; not followed, it comes
|
|
23
|
+
// back as an opaque redirect the gateway can name. A caller can still
|
|
24
|
+
// pass `redirect: "follow"`.
|
|
25
|
+
const response = await fetch(`${BASE_URL}${path}`, { ...init, headers, redirect: init?.redirect ?? "manual" });
|
|
26
|
+
if (response.type === "opaqueredirect") {
|
|
27
|
+
return { status: response.status, body: undefined, headers: response.headers, foreign: "opaque-redirect" };
|
|
28
|
+
}
|
|
29
|
+
if (response.redirected && isOtherOrigin(response.url)) {
|
|
30
|
+
return { status: response.status, body: undefined, headers: response.headers, foreign: "cross-origin-redirect" };
|
|
31
|
+
}
|
|
9
32
|
if (response.status === 204) {
|
|
10
33
|
return { status: response.status, body: undefined, headers: response.headers };
|
|
11
34
|
}
|
|
12
|
-
const
|
|
13
|
-
|
|
35
|
+
const html = (response.headers.get("content-type") ?? "").toLowerCase().includes("text/html");
|
|
36
|
+
let parsed = true;
|
|
37
|
+
const body = await response.json().catch(() => {
|
|
38
|
+
parsed = false;
|
|
39
|
+
return undefined;
|
|
40
|
+
});
|
|
41
|
+
const foreign = html ? "html" : parsed ? undefined : "not-json";
|
|
42
|
+
return foreign
|
|
43
|
+
? { status: response.status, body, headers: response.headers, foreign }
|
|
44
|
+
: { status: response.status, body, headers: response.headers };
|
|
45
|
+
}
|
|
46
|
+
function isOtherOrigin(url) {
|
|
47
|
+
const here = globalThis.location?.origin;
|
|
48
|
+
if (!here || !url)
|
|
49
|
+
return false;
|
|
50
|
+
try {
|
|
51
|
+
return new URL(url).origin !== here;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
14
56
|
}
|
|
@@ -9,7 +9,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
9
9
|
// `compact` is the same state for a small container (a WidgetCard): less
|
|
10
10
|
// padding and the icon beside the title instead of in a box above it, so
|
|
11
11
|
// one failing widget reads as that widget's problem, not the page's.
|
|
12
|
-
|
|
12
|
+
//
|
|
13
|
+
// Kind `proxy_auth` (a lapsed sign-in at a proxy in front of the app, such
|
|
14
|
+
// as Cloudflare Access) offers "Sign In Again" in place of any retry: a
|
|
15
|
+
// full page load, so the proxy's own sign-in runs. Retrying the request
|
|
16
|
+
// would only get the proxy's page again.
|
|
17
|
+
import { AlertCircleIcon, LogInIcon } from 'lucide-react';
|
|
13
18
|
import { cn } from 'cn';
|
|
14
19
|
import { Button } from '../ui/button.js';
|
|
15
20
|
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, } from '../ui/empty.js';
|
|
@@ -20,8 +25,13 @@ const TITLE_BY_KIND = {
|
|
|
20
25
|
auth: 'Not authorized',
|
|
21
26
|
rate_limited: 'Too many attempts',
|
|
22
27
|
validation: 'Check the form',
|
|
28
|
+
proxy_auth: 'Sign-in expired',
|
|
23
29
|
};
|
|
30
|
+
function reloadPage() {
|
|
31
|
+
window.location.reload();
|
|
32
|
+
}
|
|
24
33
|
export function ErrorState({ error, onRetry, size = 'default', className, }) {
|
|
25
34
|
const compact = size === 'compact';
|
|
26
|
-
|
|
35
|
+
const signInAgain = error.kind === 'proxy_auth';
|
|
36
|
+
return (_jsxs(Empty, { className: cn(compact && 'gap-3 p-4', className), "data-state": "error", "data-size": size, children: [_jsxs(EmptyHeader, { className: cn(compact && 'gap-1'), children: [compact ? (_jsxs(EmptyTitle, { className: "flex items-center gap-1.5", children: [_jsx(AlertCircleIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-destructive-text" }), TITLE_BY_KIND[error.kind]] })) : (_jsxs(_Fragment, { children: [_jsx(EmptyMedia, { variant: "icon", children: _jsx(AlertCircleIcon, { className: "text-destructive-text" }) }), _jsx(EmptyTitle, { children: TITLE_BY_KIND[error.kind] })] })), _jsx(EmptyDescription, { children: error.message })] }), signInAgain ? (_jsx(EmptyContent, { children: _jsxs(Button, { size: "sm", onClick: reloadPage, children: [_jsx(LogInIcon, { "aria-hidden": "true" }), "Sign In Again"] }) })) : (onRetry && (_jsx(EmptyContent, { children: _jsx(Button, { size: "sm", variant: "outline", onClick: onRetry, children: "Try Again" }) })))] }));
|
|
27
37
|
}
|
|
@@ -116,7 +116,7 @@ export function ModuleCard({ title, icon: Icon, category, to, href, value, note,
|
|
|
116
116
|
'data-slot': 'module-card-band',
|
|
117
117
|
className: cn(BAND_LINK_CLASS, category && BAND_CLASS[category]),
|
|
118
118
|
};
|
|
119
|
-
const card = (_jsxs(Card, { "data-slot": "module-card", "data-state": state, className: cn('glow-edge relative h-full min-w-0 gap-0 py-0', mobile === 'row' && 'max-md:hidden', className), children: [href !== undefined ? (_jsxs("a", { href: href, target: "_blank", rel: "noreferrer", ...bandProps, children: [band, _jsx(NewTabMark, {})] })) : (_jsx(Link, { to: to, ...bandProps, children: band })), _jsxs("div", { id: bodyId, "data-slot": "module-card-body", "aria-busy": state === 'loading' || undefined, className: "flex flex-1 flex-col gap-0.5 px-3 py-2 density-compact:py-1.5 max-sm:px-2", children: [state === 'error' ? (_jsxs(_Fragment, { children: [_jsxs("p", { className: "flex items-center gap-1.5 type-body text-foreground", children: [_jsx(AlertCircleIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-destructive-text" }), _jsxs("span", { className: "min-w-0", children: ["Couldn't load", error?.message && _jsxs("span", { className: "sr-only", children: [": ", error.message] })] })] }), onRetry && (_jsx(Button, { size: "sm", variant: "outline", onClick: onRetry, "aria-describedby": titleId, className: "relative z-10 mt-1 self-start", children: "Retry" }))] })) : state === 'loading' ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children: "Loading" }), _jsx(Skeleton, { "data-state": "loading", className: "my-0.5 h-6 w-12" })] })) : (value !== undefined && (_jsx("span", { "data-slot": "module-card-value", className: "type-numeric text-foreground", children: value }))), note && state !== 'error' && (_jsx("span", { className: "truncate type-body text-muted-foreground", title: note, children: note }))] }), action &&
|
|
119
|
+
const card = (_jsxs(Card, { "data-slot": "module-card", "data-state": state, className: cn('glow-edge relative h-full min-w-0 gap-0 py-0', mobile === 'row' && 'max-md:hidden', className), children: [href !== undefined ? (_jsxs("a", { href: href, target: "_blank", rel: "noreferrer", ...bandProps, children: [band, _jsx(NewTabMark, {})] })) : (_jsx(Link, { to: to, ...bandProps, children: band })), _jsxs("div", { id: bodyId, "data-slot": "module-card-body", "aria-busy": state === 'loading' || undefined, className: "flex flex-1 flex-col gap-0.5 px-3 py-2 density-compact:py-1.5 max-sm:px-2", children: [state === 'error' ? (_jsxs(_Fragment, { children: [_jsxs("p", { className: "flex items-center gap-1.5 type-body text-foreground", children: [_jsx(AlertCircleIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-destructive-text" }), _jsxs("span", { className: "min-w-0", children: ["Couldn't load", error?.message && _jsxs("span", { className: "sr-only", children: [": ", error.message] })] })] }), error?.kind === 'proxy_auth' ? (_jsx(Button, { size: "sm", variant: "outline", onClick: () => window.location.reload(), "aria-describedby": titleId, className: "relative z-10 mt-1 self-start", children: "Sign In Again" })) : (onRetry && (_jsx(Button, { size: "sm", variant: "outline", onClick: onRetry, "aria-describedby": titleId, className: "relative z-10 mt-1 self-start", children: "Retry" })))] })) : state === 'loading' ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children: "Loading" }), _jsx(Skeleton, { "data-state": "loading", className: "my-0.5 h-6 w-12" })] })) : (value !== undefined && (_jsx("span", { "data-slot": "module-card-value", className: "type-numeric text-foreground", children: value }))), note && state !== 'error' && (_jsx("span", { className: "truncate type-body text-muted-foreground", title: note, children: note }))] }), action &&
|
|
120
120
|
(action.href !== undefined ? (_jsxs("a", { href: action.href, target: "_blank", rel: "noreferrer", "aria-describedby": titleId, className: ACTION_CLASS, children: [_jsx("span", { className: "truncate", children: action.label }), _jsx(NewTabMark, {})] })) : (_jsx(Link, { to: action.to, "aria-describedby": titleId, className: ACTION_CLASS, children: _jsx("span", { className: "truncate", children: action.label }) })))] }));
|
|
121
121
|
if (mobile === 'tiles')
|
|
122
122
|
return card;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useRender } from "@base-ui/react/use-render";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const badgeVariants: (props?: ({
|
|
4
|
-
variant?: "
|
|
4
|
+
variant?: "default" | "link" | "success" | "outline" | "secondary" | "ghost" | "destructive" | "solid" | "info" | "warning" | "outline-success" | "outline-warning" | "outline-info" | "outline-destructive" | "tinted-success" | "tinted-warning" | "tinted-info" | "tinted-destructive" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
declare function Badge({ className, variant, render, ...props }: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
7
7
|
export { Badge, badgeVariants };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
|
-
variant?: "
|
|
4
|
+
variant?: "default" | "link" | "outline" | "secondary" | "ghost" | "destructive" | null | undefined;
|
|
5
5
|
size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
declare function Button({ className, variant, size, ...props }: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>): import("react").JSX.Element;
|
package/dist/gateway.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { networkError, safeFetch, toAppError } from './api/gateway/errors.js';
|
|
1
|
+
export { networkError, proxyAuthError, safeFetch, toAppError } from './api/gateway/errors.js';
|
|
2
2
|
export type { ApiResponse } from './api/transport/index.js';
|
package/dist/gateway.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// (src/api/gateway/<entity>.ts) build on: the single fetch path and the
|
|
3
3
|
// wire-error -> AppError translation. Lint allows importing this only from
|
|
4
4
|
// src/api/gateway/, which is what keeps every other layer off the network.
|
|
5
|
-
export { networkError, safeFetch, toAppError } from './api/gateway/errors.js';
|
|
5
|
+
export { networkError, proxyAuthError, safeFetch, toAppError } from './api/gateway/errors.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.107.0",
|
|
4
4
|
"description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|