@pramen/admin 0.0.48 → 0.0.50
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/dist/app.css +1 -1
- package/dist/index.html +1 -1
- package/dist/{main.3q5j5mrq.js → main.hp8e75nt.js} +73 -73
- package/package.json +4 -4
- package/src/api.ts +12 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pramen/admin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.50",
|
|
4
4
|
"description": "pramen admin dashboard — a Preact single-page browser client for the pramen admin HTTP API (tenants, schema, and generic row browse/edit).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@podoba/react": "^0.0.
|
|
25
|
-
"@podoba/tokens": "^0.0.
|
|
26
|
-
"@podoba/tailwind": "^0.0.
|
|
24
|
+
"@podoba/react": "^0.0.34",
|
|
25
|
+
"@podoba/tokens": "^0.0.34",
|
|
26
|
+
"@podoba/tailwind": "^0.0.34",
|
|
27
27
|
"react": "^19.0.0",
|
|
28
28
|
"react-dom": "^19.0.0"
|
|
29
29
|
},
|
package/src/api.ts
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
// bearer token; failures surface as an ApiError that the UI renders verbatim
|
|
3
3
|
// (error + code), with a friendlier hint for a 403 (not an admin token).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/** Any JSON value. Declared locally (not imported from @pramen/server) so the admin
|
|
6
|
+
* stays a standalone browser bundle with no server-package dependency. */
|
|
7
|
+
export type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
|
|
8
|
+
|
|
9
|
+
/** One row of admin data, as the `/admin/data` endpoint returns it. */
|
|
10
|
+
export type Row = Record<string, JsonValue>;
|
|
6
11
|
|
|
7
12
|
export interface SchemaResult {
|
|
8
13
|
hash: string | null;
|
|
@@ -34,16 +39,14 @@ interface Envelope<T> {
|
|
|
34
39
|
|
|
35
40
|
async function call<T>(cfg: Config, path: string, init?: RequestInit): Promise<T> {
|
|
36
41
|
const base = cfg.baseUrl.replace(/\/+$/, "");
|
|
42
|
+
const headers = new Headers();
|
|
43
|
+
if (init?.body) headers.set("content-type", "application/json");
|
|
44
|
+
headers.set("authorization", `Bearer ${cfg.token}`);
|
|
45
|
+
// caller-supplied headers win, matching the previous spread order
|
|
46
|
+
for (const [key, value] of new Headers(init?.headers)) headers.set(key, value);
|
|
37
47
|
let res: Response;
|
|
38
48
|
try {
|
|
39
|
-
res = await fetch(`${base}${path}`, {
|
|
40
|
-
...init,
|
|
41
|
-
headers: {
|
|
42
|
-
...(init?.body ? { "content-type": "application/json" } : {}),
|
|
43
|
-
authorization: `Bearer ${cfg.token}`,
|
|
44
|
-
...(init?.headers ?? {}),
|
|
45
|
-
},
|
|
46
|
-
});
|
|
49
|
+
res = await fetch(`${base}${path}`, { ...init, headers });
|
|
47
50
|
} catch (e) {
|
|
48
51
|
throw new ApiError(
|
|
49
52
|
`network error reaching ${base} — is pramen running and is CORS_ORIGINS set?`,
|