@redbase/sdk 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wender Lima / Rednew Ventures
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # @redbase/sdk
2
+
3
+ Official TypeScript SDK for [RedBase](https://redbase.dev) — a backend-as-a-service platform. If you're looking for an alternative to Supabase, this is it.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @redbase/sdk
9
+ # or
10
+ pnpm add @redbase/sdk
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```ts
16
+ import { createClient } from '@redbase/sdk'
17
+
18
+ const rb = createClient(
19
+ 'https://api.redbase.dev',
20
+ 'your-anon-key'
21
+ )
22
+ ```
23
+
24
+ ### Authentication
25
+
26
+ ```ts
27
+ // Sign up a new user
28
+ const { data, error } = await rb.auth.signUp({
29
+ email: 'user@example.com',
30
+ password: 'securepassword',
31
+ })
32
+
33
+ // Sign in
34
+ const { data, error } = await rb.auth.signInWithPassword({
35
+ email: 'user@example.com',
36
+ password: 'securepassword',
37
+ })
38
+
39
+ // Get current session
40
+ const { data: { session } } = await rb.auth.getSession()
41
+
42
+ // Sign out
43
+ await rb.auth.signOut()
44
+ ```
45
+
46
+ ### Data Queries
47
+
48
+ Query your tables with the `from()` method:
49
+
50
+ ```ts
51
+ // Select rows
52
+ const { data, error } = await rb.from('users').select('*')
53
+
54
+ // Select specific columns
55
+ const { data } = await rb.from('posts').select('id, title, created_at')
56
+
57
+ // Filter with conditions
58
+ const { data } = await rb.from('posts')
59
+ .select('*')
60
+ .eq('status', 'published')
61
+ .order('created_at', { ascending: false })
62
+
63
+ // Insert
64
+ await rb.from('posts').insert({ title: 'Hello World', status: 'draft' })
65
+
66
+ // Update
67
+ await rb.from('posts').update({ status: 'published' }).eq('id', 1)
68
+
69
+ // Delete
70
+ await rb.from('posts').delete().eq('id', 1)
71
+ ```
72
+
73
+ ### Storage
74
+
75
+ Upload and manage files:
76
+
77
+ ```ts
78
+ // List files in a bucket
79
+ const { data: files } = await rb.storage.from('photos').list()
80
+
81
+ // Upload a file
82
+ await rb.storage.from('photos').upload('avatar.png', file)
83
+
84
+ // Get a public URL
85
+ const { data } = rb.storage.from('photos').getPublicUrl('avatar.png')
86
+
87
+ // Download a file
88
+ const { data, error } = await rb.storage.from('photos').download('avatar.png')
89
+ ```
90
+
91
+ ### Email (Server-Side Only)
92
+
93
+ Send transactional emails with `email.send()`. This requires the **service role key** and should only be called from server-side code (API routes, edge functions, etc.).
94
+
95
+ ```ts
96
+ import { createClient } from '@redbase/sdk'
97
+
98
+ const rb = createClient(
99
+ process.env.REDBASE_URL!,
100
+ process.env.REDBASE_SERVICE_ROLE_KEY!
101
+ )
102
+
103
+ const { success, messageId, error } = await rb.email.send({
104
+ to: 'user@example.com',
105
+ subject: 'Welcome!',
106
+ html: '<h1>Welcome to our app!</h1>',
107
+ text: 'Welcome to our app!', // optional plain text fallback
108
+ replyTo: 'support@example.com', // optional
109
+ cc: ['team@example.com'], // optional
110
+ bcc: ['logs@example.com'], // optional
111
+ })
112
+
113
+ if (!success) {
114
+ console.error('Email failed:', error)
115
+ }
116
+ ```
117
+
118
+ ## TypeScript Support
119
+
120
+ Use database types for full type safety:
121
+
122
+ ```ts
123
+ import { createClient } from '@redbase/sdk'
124
+ import type { Database } from './database.types'
125
+
126
+ const rb = createClient<Database>(
127
+ 'https://api.redbase.dev',
128
+ 'your-anon-key'
129
+ )
130
+
131
+ // Queries are fully typed
132
+ const { data } = await rb.from('users').select('id, email, created_at')
133
+ // data is typed as { id: string; email: string; created_at: string }[] | null
134
+ ```
135
+
136
+ ## API Reference
137
+
138
+ ### `createClient(url, key, options?)`
139
+
140
+ Creates a RedBase client instance.
141
+
142
+ | Parameter | Type | Description |
143
+ |-----------|------|-------------|
144
+ | `url` | `string` | RedBase API URL (e.g., `https://api.redbase.dev`) |
145
+ | `key` | `string` | API key — anon key for client-side, service role key for server-side |
146
+ | `options` | `RedbaseClientOptions` | Optional client configuration |
147
+
148
+ Returns a `RedbaseClient` with:
149
+ - `auth` — Authentication methods (signUp, signIn, signOut, getSession, etc.)
150
+ - `from(table)` — Query builder for database tables
151
+ - `storage` — File storage operations
152
+ - `email` — Transactional email (server-side only)
153
+
154
+ ### `email.send(options)`
155
+
156
+ | Option | Type | Required | Description |
157
+ |--------|------|----------|-------------|
158
+ | `to` | `string \| string[]` | Yes | Recipient email address(es) |
159
+ | `subject` | `string` | Yes | Email subject line |
160
+ | `html` | `string` | Yes | HTML body content |
161
+ | `text` | `string` | No | Plain text fallback |
162
+ | `replyTo` | `string` | No | Reply-to address |
163
+ | `cc` | `string \| string[]` | No | CC recipients |
164
+ | `bcc` | `string \| string[]` | No | BCC recipients |
165
+
166
+ Returns: `Promise<{ success: boolean; messageId?: string; error?: string }>`
167
+
168
+ ## Exported Types
169
+
170
+ ```ts
171
+ import {
172
+ createClient,
173
+ RedbaseClient,
174
+ RedbaseClientOptions,
175
+
176
+ // Auth types
177
+ Session,
178
+ User,
179
+ AuthError,
180
+ AuthResponse,
181
+
182
+ // Database types
183
+ PostgrestError,
184
+ PostgrestResponse,
185
+
186
+ // Email types
187
+ EmailClient,
188
+ EmailSendOptions,
189
+ EmailSendResponse,
190
+
191
+ // Realtime types
192
+ RealtimeChannel,
193
+ } from '@redbase/sdk'
194
+ ```
195
+
196
+ ## Links
197
+
198
+ - [RedBase](https://redbase.dev)
199
+ - [API](https://api.redbase.dev)
200
+ - [GitHub](https://github.com/wender/redbase-sdk)
201
+
202
+ ## License
203
+
204
+ MIT