@fluxbase/sdk 0.0.1-rc.10
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/README.md +141 -0
- package/dist/index.cjs +3788 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4021 -0
- package/dist/index.d.ts +4021 -0
- package/dist/index.js +3764 -0
- package/dist/index.js.map +1 -0
- package/package.json +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# @fluxbase/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript/JavaScript SDK for Fluxbase - Backend as a Service.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@fluxbase/sdk)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Type-safe** - Full TypeScript support with generated types
|
|
11
|
+
- **Database Queries** - PostgREST-compatible query builder with filters, ordering, pagination
|
|
12
|
+
- **Aggregations** - Count, sum, avg, min, max with GROUP BY support
|
|
13
|
+
- **Batch Operations** - Efficient multi-row insert, update, delete
|
|
14
|
+
- **Authentication** - JWT-based auth with automatic token refresh
|
|
15
|
+
- **Realtime** - WebSocket subscriptions to database changes
|
|
16
|
+
- **Storage** - File upload/download with S3 compatibility
|
|
17
|
+
- **RPC** - Call PostgreSQL functions directly
|
|
18
|
+
- **Lightweight** - Zero dependencies except fetch polyfill
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @fluxbase/sdk
|
|
24
|
+
# or
|
|
25
|
+
yarn add @fluxbase/sdk
|
|
26
|
+
# or
|
|
27
|
+
pnpm add @fluxbase/sdk
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { createClient } from '@fluxbase/sdk'
|
|
34
|
+
|
|
35
|
+
// Create a client
|
|
36
|
+
const client = createClient({
|
|
37
|
+
url: 'http://localhost:8080',
|
|
38
|
+
auth: {
|
|
39
|
+
autoRefresh: true,
|
|
40
|
+
persist: true,
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
// Authentication
|
|
45
|
+
await client.auth.signUp({
|
|
46
|
+
email: 'user@example.com',
|
|
47
|
+
password: 'secure-password',
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// Query data
|
|
51
|
+
const { data } = await client
|
|
52
|
+
.from('products')
|
|
53
|
+
.select('*')
|
|
54
|
+
.eq('category', 'electronics')
|
|
55
|
+
.gte('price', 100)
|
|
56
|
+
.execute()
|
|
57
|
+
|
|
58
|
+
// Aggregations
|
|
59
|
+
const stats = await client
|
|
60
|
+
.from('products')
|
|
61
|
+
.count('*')
|
|
62
|
+
.groupBy('category')
|
|
63
|
+
.execute()
|
|
64
|
+
|
|
65
|
+
// Realtime subscriptions
|
|
66
|
+
client.realtime
|
|
67
|
+
.channel('table:public.products')
|
|
68
|
+
.on('INSERT', (payload) => console.log('New:', payload.new_record))
|
|
69
|
+
.subscribe()
|
|
70
|
+
|
|
71
|
+
// File upload
|
|
72
|
+
await client.storage
|
|
73
|
+
.from('avatars')
|
|
74
|
+
.upload('user-123.png', file)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Documentation
|
|
78
|
+
|
|
79
|
+
📚 **[Complete Documentation](../../docs/docs/sdks/getting-started.md)**
|
|
80
|
+
|
|
81
|
+
### Core Guides
|
|
82
|
+
- **[Getting Started](../../docs/docs/sdks/getting-started.md)** - Installation, configuration, and basic usage
|
|
83
|
+
- **[Database Operations](../../docs/docs/sdks/database.md)** - Queries, filters, aggregations, batch operations, and RPC
|
|
84
|
+
- **[React Hooks](../../docs/docs/sdks/react-hooks.md)** - React integration with `@fluxbase/sdk-react`
|
|
85
|
+
|
|
86
|
+
### API Reference
|
|
87
|
+
- **[TypeScript API Docs](../../docs/static/api/sdk/)** - Auto-generated from source code
|
|
88
|
+
|
|
89
|
+
## Browser & Node.js Support
|
|
90
|
+
|
|
91
|
+
- **Browsers**: All modern browsers with ES6+ and Fetch API
|
|
92
|
+
- **Node.js**: v18+ (native fetch) or v16+ with `cross-fetch` polyfill
|
|
93
|
+
|
|
94
|
+
## TypeScript Support
|
|
95
|
+
|
|
96
|
+
Fully typed with TypeScript. Define your schemas for complete type safety:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
interface Product {
|
|
100
|
+
id: number
|
|
101
|
+
name: string
|
|
102
|
+
price: number
|
|
103
|
+
category: string
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const { data } = await client.from<Product>('products').select('*').execute()
|
|
107
|
+
// data is typed as Product[]
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Examples
|
|
111
|
+
|
|
112
|
+
Check out working examples in the [`/example`](../example/) directory:
|
|
113
|
+
- Vanilla JavaScript/TypeScript
|
|
114
|
+
- React with hooks
|
|
115
|
+
- Next.js integration
|
|
116
|
+
- Vue 3 integration
|
|
117
|
+
|
|
118
|
+
## React Integration
|
|
119
|
+
|
|
120
|
+
For React applications, use [`@fluxbase/sdk-react`](../sdk-react/) for hooks and automatic state management:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npm install @fluxbase/sdk @fluxbase/sdk-react @tanstack/react-query
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
See the **[React Hooks Guide](../../docs/docs/sdks/react-hooks.md)** for details.
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
Contributions are welcome! Please read our [Contributing Guide](../../CONTRIBUTING.md) for details.
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT © Fluxbase
|
|
135
|
+
|
|
136
|
+
## Links
|
|
137
|
+
|
|
138
|
+
- [Documentation](../../docs/docs/sdks/getting-started.md)
|
|
139
|
+
- [API Reference](../../docs/static/api/sdk/)
|
|
140
|
+
- [GitHub](https://github.com/wayli-app/fluxbase)
|
|
141
|
+
- [Issues](https://github.com/wayli-app/fluxbase/issues)
|