TypeScript SDK
Lovrabet TypeScript SDK (@lovrabet/sdk) is the core client library that connects frontend applications to the Lovrabet data platform, providing complete data operation capabilities through a minimalist API.
Product Positioning
Lovrabet is an AI-Native business system generation platform. It uses the pioneering DBAgent database reverse-engineering technology to automatically analyze business models and generate server-side APIs. The TypeScript SDK serves as the platform's BaaS data access layer: shielding developers from underlying API complexity and enabling platform data operations with a native TypeScript experience.
One-line value proposition: With 5 lines of code, go from zero to full data read/write in any frontend project, without needing to understand any API details.
Core Technical Highlights
Four Authentication Modes Covering All Business Scenarios
| Authentication Method | Runtime Environment | Mechanism | Use Cases |
|---|---|---|---|
| OpenAPI (Server-side) | Node.js | accessKey + HMAC-SHA256 signing, server-side token generation | Backend services, SSR, data scripts |
| OpenAPI (Browser) | Browser | Pre-generated token + timestamp, no key exposure risk | Pure frontend apps, post-SSR browser side |
| Client AK (Server-side) | Node.js | accessKey + X-User-AK, calls /client/* endpoints directly | Server-side scripts, OCR / file platform services (v1.4.1+) |
| WebAPI (Cookie) | Browser / Node.js | Cookie string carrying user-session authentication | Client-side operations for logged-in platform users |
Key Security Design: accessKey never reaches the browser; OpenAPI tokens have a 10-minute validity period; tokens are generated server-side, ensuring no key exposure on the browser side.
Unified CRUD + Advanced Queries, One API for Everything
// List query — filter supports rich conditions and sorting
const users = await client.models.users.filter({
where: { status: "active", age: { $gte: 18 } },
orderBy: [{ createdAt: "desc" }],
pageSize: 20
});
// Create, update, delete — single or batch (up to 1000 records)
await client.models.users.update([1, 2, 3], { status: "inactive" });
await client.models.users.delete([4, 5, 6]);
// Aggregate queries — count/sum/avg, no need to write SQL
const stats = await client.models.orders.aggregate({
groupBy: ["status"],
aggregations: [{ field: "amount", type: "sum", alias: "total" }]
});
Native TypeScript Experience, AI-Friendly
- Complete Type Definitions: 40+ exported types,
WhereCondition,FilterParams,AggregateParamsall independently referenceable - Generic Support:
client.models.users.filter<User>()returnsUsertype with IDE auto-completion - AI Error Descriptions:
LovrabetErrorcarriescode,message,descriptionwith fix suggestions in error messages
True Cross-Platform Compatibility, One Codebase
- Built on native fetch, no extra HTTP dependencies
- HMAC-SHA256 signing supports both Web Crypto API (browser) and Node.js
crypto - One codebase runs on: React / Vue / Angular / Svelte, Node.js / Express / Koa / Nest.js, WeChat Mini Programs / Electron
Developer Experience
- Zero-config entry:
registerModels()once, reference everywhere - Seamless multi-environment switching:
production/daily/developmentin one line - Batch operations: Update/delete up to 1000 records, reducing network round trips
- SQL / BFF endpoints: Call platform pre-registered custom SQL and backend functions via SDK
Version History
| Version | Description |
|---|---|
| v1.4.3 | Platform services client.services (OCR / file), Client AK auth, batchCreate() |
| v1.4.2 | Aggregate param column alignment (field kept as alias) |
| v1.4.1 | Client AK auth, explicit authMode (Breaking), batchCreate(), $notNull |
| v1.3.7 | Batch operations (1000 records), aggregate queries aggregate() |
| v1.2.0 | Model aliases, BFF endpoint calls |
| v1.1.19 | SQL API |
| v1.1.14 | Node.js Cookie authentication support |
| v1.1.0 | Initial release |
Documentation Directory
Getting Started
- SDK Introduction — SDK overview, technical features, core capabilities
- Quick Start — 5-minute getting started guide
- Configuration Details — Multiple configuration methods and multi-project support
- Authentication Configuration — Four authentication methods (incl. Client AK) configuration and security notes
Data Operations
- API Usage Guide — CRUD operations, query parameters, batch processing
- Filter API — Complex condition filtering, field selection, multi-field sorting
- Aggregate API — Group statistics, sum, average
- SQL API — Execute platform pre-registered custom SQL
- BFF API — Call backend functions
- User List Query — User list query examples
- Multi-Table Query — Multi-table join queries
- Platform Services (OCR / File) —
client.servicesOCR recognition and file upload / access URL (v1.4.3+)
Advanced Features
- Model Aliases — Friendly alias access methods
- Advanced Features — Multi-project management, performance optimization, error handling
- Error Handling — LovrabetError details and debugging tips
- Syntax Sugar — Convenient shorthand provided by SDK
- TypeScript Support — Type definitions and type-safe development
- SQL Tutorial — SQL basics tutorial
Reference
- API Reference — Complete API reference documentation
- MCP SDK Usage — MCP SDK integration guide
- Practical Examples — Complete integration examples for React, Vue, Node.js, etc.
- Troubleshooting — Common problem diagnosis and solutions
- Frontend Platform — Frontend platform related features
This documentation is maintained by Claude Code and auto-generated from Feishu Wiki sources.