khotan-data 0.1.0 → 0.2.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.
@@ -4,6 +4,7 @@ import { useEffect, useState, useCallback } from "react";
4
4
  import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
5
5
  import { Badge } from "@/components/ui/badge";
6
6
  import { Button } from "@/components/ui/button";
7
+ import { khotanFetch, ApiErrorState } from "./api-state";
7
8
 
8
9
  // ============================================================================
9
10
  // Wire Panel — UI for managing webhook subscriptions
@@ -45,21 +46,23 @@ export function WirePanel({
45
46
  const [loading, setLoading] = useState(true);
46
47
  const [acting, setActing] = useState(false);
47
48
  const [error, setError] = useState<string | null>(null);
49
+ const [loadError, setLoadError] = useState<unknown>(null);
48
50
 
49
51
  const fetchWire = useCallback(async () => {
52
+ setLoading(true);
53
+ setLoadError(null);
50
54
  try {
51
- const res = await fetch(`${basePath}/wires/${plugName}`);
52
- if (!res.ok) {
53
- setConfigured(false);
54
- setWire(null);
55
- return;
56
- }
57
- const data = await res.json();
55
+ const data = await khotanFetch<{
56
+ configured?: boolean;
57
+ wire?: WireRecord | null;
58
+ }>(`${basePath}/wires/${plugName}`);
58
59
  setConfigured(data.configured ?? false);
59
60
  setWire(data.wire ?? null);
60
61
  setError(null);
61
- } catch {
62
+ } catch (err) {
62
63
  setConfigured(false);
64
+ setWire(null);
65
+ setLoadError(err);
63
66
  } finally {
64
67
  setLoading(false);
65
68
  }
@@ -136,6 +139,25 @@ export function WirePanel({
136
139
  );
137
140
  }
138
141
 
142
+ if (loadError) {
143
+ return (
144
+ <Card>
145
+ <CardHeader className="pb-2">
146
+ <CardTitle className="text-sm font-medium capitalize">
147
+ {displayName} Wire
148
+ </CardTitle>
149
+ </CardHeader>
150
+ <CardContent>
151
+ <ApiErrorState
152
+ error={loadError}
153
+ onRetry={() => void fetchWire()}
154
+ compact
155
+ />
156
+ </CardContent>
157
+ </Card>
158
+ );
159
+ }
160
+
139
161
  if (!configured) return null;
140
162
 
141
163
  const isActive = wire?.status === "active";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "khotan-data",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Data primitives for TypeScript — ETL pipelines, transforms, and Drizzle Postgres integration.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",