mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 22:04:56 +00:00
Integrated DBAL components throughout the application:
**Integration Layer (`src/lib/dbal-integration.ts`):**
- Singleton DBALIntegration class
- Manages DBAL client, tenant manager, KV store, and blob storage
- Provides high-level API for all DBAL operations
- Automatic tenant scoping (default tenant)
- Error handling utilities
**React Hooks (`src/hooks/useDBAL.ts`):**
- `useDBAL()` - Initialize and check DBAL readiness
- `useKVStore()` - Key-value store operations with auto error handling
- `useBlobStorage()` - Blob storage operations with toast notifications
- `useCachedData()` - Automatic caching with React state management
**Demo Component (`src/components/DBALDemo.tsx`):**
- Comprehensive demonstration of all DBAL features
- Three tabs: KV Store, Blob Storage, Cached Data
- Interactive examples with forms and buttons
- Real-time feedback with toast notifications
- Shows best practices for DBAL usage
**Path Configuration:**
- Updated `tsconfig.json` with `@/dbal/*` path alias
- Updated `vite.config.ts` with dbal path resolution
- Enables clean imports: `import { DBALClient } from '@/dbal/ts/src'`
**Features Integrated:**
- **Key-Value Store**: Store/retrieve any JSON-serializable data
- **List Management**: Arrays with add/get operations
- **Blob Storage**: Upload/download binary data (images, files)
- **Multi-Tenant**: Automatic tenant isolation (default tenant)
- **TTL Support**: Automatic expiration for cached data
- **Metadata**: Store custom metadata with blobs
- **Error Handling**: Graceful error handling with user feedback
**Usage Examples:**
```typescript
// In any component
import { useKVStore } from '@/hooks/useDBAL'
const kv = useKVStore()
await kv.set('user-prefs', { theme: 'dark' }, 3600)
const prefs = await kv.get('user-prefs')
// Blob storage
import { useBlobStorage } from '@/hooks/useDBAL'
const blob = useBlobStorage()
await blob.upload('avatar.png', imageData)
// Cached data
import { useCachedData } from '@/hooks/useDBAL'
const { data, save } = useCachedData('settings')
await save({ notifications: true })
```
**Documentation:**
- Complete integration guide (DBAL_INTEGRATION.md)
- Architecture diagrams
- API reference
- Usage examples
- Troubleshooting guide
**TypeScript Support:**
- Full type safety with generics
- IntelliSense support for all APIs
- Type-safe error handling
**Production Ready:**
- In-memory adapter for browser (development)
- HTTP adapter ready for C++ daemon (production)
- Multi-tenant support with quotas
- Access control ready
- Error handling and logging
Next steps: Use DBAL hooks in existing components to replace localStorage/sessionStorage.
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
41 lines
834 B
JSON
41 lines
834 B
JSON
{
|
|
"compilerOptions": {
|
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
"target": "ES2020",
|
|
"useDefineForClassFields": true,
|
|
"lib": [
|
|
"ES2020",
|
|
"DOM",
|
|
"DOM.Iterable"
|
|
],
|
|
"module": "ESNext",
|
|
"skipLibCheck": true,
|
|
"strictNullChecks": true,
|
|
/* Bundler mode */
|
|
"moduleResolution": "bundler",
|
|
"allowImportingTsExtensions": true,
|
|
"isolatedModules": true,
|
|
"moduleDetection": "force",
|
|
"noEmit": true,
|
|
"jsx": "react-jsx",
|
|
/* Linting */
|
|
"noFallthroughCasesInSwitch": true,
|
|
"noUncheckedSideEffectImports": true,
|
|
"paths": {
|
|
"@/*": [
|
|
"./src/*"
|
|
],
|
|
"@/dbal/*": [
|
|
"./dbal/*"
|
|
]
|
|
},
|
|
},
|
|
"include": [
|
|
"src",
|
|
"packages",
|
|
"e2e",
|
|
"playwright.config.ts",
|
|
"vite.config.ts"
|
|
]
|
|
}
|