refactor: improve auth defaults, update UI, and docs

- Provide fallback values for auth environment variables
- Refine global CSS styles and typography
- Update application metadata descriptions
- Add toast error handling to clients page
- Formalize phase implementation guidelines in AGENTS.md
This commit is contained in:
Team Dark Devil committed 2026-11-16 21:58:18 +06:00
1 parent df14ee1a9a
commit fde2c86b1e
48 files changed
+1062 -1665

No files matched your search

+51 -70
View File
@@ -1,8 +1,11 @@
'use client';
import { AdminPageHeader } from '@/components/layout/AdminPageHeader';
import { Button } from '@/components/ui/Button';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/Card';
import { Card } from '@/components/ui/Card';
import { CodeBlock } from '@/components/ui/CodeBlock';
import { Select } from '@/components/ui/Input';
import { Panel } from '@/components/ui/Panel';
import { useToast } from '@/components/ui/Toast';
import { useEffect, useState } from 'react';
@@ -35,102 +38,80 @@ export default function SdkGuidePage() {
const pythonSnippet = `from datastack_sdk import DataStackClient
# Initialize client using credentials generated in /vcon/clients
client = DataStackClient(
server_url="http://localhost:4000",
token="${sampleToken}"
)
# Connect with automatic reconnection backoff
if client.connect():
# 1. Sync single event in realtime
res = client.sync({
"event_type": "page_view",
"url": "/products/wireless-headphones",
"user_id": "usr_9942",
"referrer": "google.com"
"user_id": "usr_9942"
})
print("Sync response:", res)
# 2. Sync high-throughput batch of records
batch_res = client.batch_sync([
{"sensor": "temp", "value": 24.5, "unit": "C"},
{"sensor": "humidity", "value": 61.2, "unit": "%"},
{"sensor": "pressure", "value": 1013.25, "unit": "hPa"}
{"sensor": "humidity", "value": 61.2, "unit": "%"}
])
print("Batch response:", batch_res)
client.disconnect()
`;
client.disconnect()`;
const copySnippet = (text: string, label: string) => {
navigator.clipboard.writeText(text);
success('Copied', `${label} copied to clipboard`);
success('Copied', `${label} copied`);
};
return (
<div className="flex flex-col gap-4 max-w-[960px]">
{/* Header */}
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-2 border-b border-[var(--border)] pb-2">
<h1 className="text-[22px] font-semibold text-[var(--text)]">
Python SDK
</h1>
<Button
size="xs"
variant="secondary"
icon="Copy"
onClick={() => copySnippet(pythonSnippet, 'Python Snippet')}
className="self-start sm:self-auto"
>
Copy Code
</Button>
</div>
{/* Installation Step */}
<Card compact className="flex flex-col gap-3 font-mono text-[13px]">
<div className="p-3 bg-[var(--bg-main)] border border-[var(--border)] flex items-center justify-between">
<span className="text-[var(--accent)]">pip install ./sdk-python</span>
<section className="flex w-full flex-col gap-2.5">
<AdminPageHeader
title="Python SDK"
actions={
<Button
size="xs"
variant="ghost"
variant="secondary"
icon="Copy"
onClick={() => copySnippet('pip install ./sdk-python', 'Pip command')}
/>
</div>
onClick={() => copySnippet(pythonSnippet, 'Snippet')}
>
Copy Code
</Button>
}
/>
<Card compact className="flex items-center justify-between bg-[var(--surface)] px-3 py-2 font-mono text-[11.5px]">
<span className="text-[var(--accent)]">pip install ./sdk-python</span>
<Button
size="xs"
variant="ghost"
icon="Copy"
onClick={() => copySnippet('pip install ./sdk-python', 'Pip command')}
/>
</Card>
{/* Interactive Code Generator */}
<Card compact className="flex flex-col gap-2">
<CardHeader className="p-0 pb-1 mb-0 border-b-0">
<div className="flex flex-wrap items-center justify-between gap-2 w-full">
<CardTitle>Client Code Example</CardTitle>
{clients.length > 0 && (
<div className="w-[180px]">
<Select
compact
value={selectedClientId}
onChange={(e) => setSelectedClientId(e.target.value)}
>
{clients.map((c) => (
<option key={c.clientId} value={c.clientId}>
{c.clientId}
</option>
))}
</Select>
</div>
)}
</div>
</CardHeader>
<CardContent className="p-0 flex flex-col gap-1">
<div className="relative">
<pre className="p-4 bg-[var(--bg-main)] border border-[var(--border)] text-[var(--text)] text-[12px] font-mono overflow-x-auto leading-relaxed">
{pythonSnippet}
</pre>
</div>
</CardContent>
</Card>
</div>
<Panel
title="Client Snippet"
action={
clients.length > 0 ? (
<div className="w-[170px]">
<Select
compact
value={selectedClientId}
onChange={(e) => setSelectedClientId(e.target.value)}
>
{clients.map((c) => (
<option key={c.clientId} value={c.clientId}>
{c.clientId}
</option>
))}
</Select>
</div>
) : undefined
}
>
<CodeBlock>{pythonSnippet}</CodeBlock>
</Panel>
</section>
);
}