@linabase/js 0.1.0 → 0.1.1
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 +137 -0
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# @linabase/js
|
|
2
|
+
|
|
3
|
+
JavaScript/TypeScript client SDK for [Linabase](https://linabase.com), the self-hostable Supabase alternative.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @linabase/js
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { createClient } from "@linabase/js";
|
|
15
|
+
|
|
16
|
+
const linabase = createClient({
|
|
17
|
+
url: "https://your-project.linabase.com",
|
|
18
|
+
anonKey: "lb_your_anon_key",
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Database
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// Select
|
|
26
|
+
const { data, error } = await linabase.from("posts").select("id, title, author(name)");
|
|
27
|
+
|
|
28
|
+
// Insert
|
|
29
|
+
await linabase.from("posts").insert({ title: "Hello", body: "World" });
|
|
30
|
+
|
|
31
|
+
// Update
|
|
32
|
+
await linabase.from("posts").update({ title: "Updated" }).eq("id", 1);
|
|
33
|
+
|
|
34
|
+
// Delete
|
|
35
|
+
await linabase.from("posts").delete().eq("id", 1);
|
|
36
|
+
|
|
37
|
+
// Filters
|
|
38
|
+
await linabase.from("posts")
|
|
39
|
+
.select()
|
|
40
|
+
.eq("status", "published")
|
|
41
|
+
.gte("created_at", "2026-01-01")
|
|
42
|
+
.order("created_at", { ascending: false })
|
|
43
|
+
.limit(10);
|
|
44
|
+
|
|
45
|
+
// RPC (call Postgres functions)
|
|
46
|
+
const result = await linabase.rpc("my_function", { arg1: "value" });
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Storage
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const storage = linabase.storage.from("avatars");
|
|
53
|
+
|
|
54
|
+
// Upload
|
|
55
|
+
await storage.upload("user-1/photo.jpg", file);
|
|
56
|
+
|
|
57
|
+
// Download
|
|
58
|
+
const blob = await storage.download("user-1/photo.jpg");
|
|
59
|
+
|
|
60
|
+
// List files
|
|
61
|
+
const files = await storage.list("user-1/");
|
|
62
|
+
|
|
63
|
+
// Get public URL
|
|
64
|
+
const url = storage.getPublicUrl("user-1/photo.jpg");
|
|
65
|
+
|
|
66
|
+
// Signed URLs
|
|
67
|
+
const { signedUrl } = await storage.createSignedUrl("user-1/photo.jpg", 3600);
|
|
68
|
+
|
|
69
|
+
// Delete
|
|
70
|
+
await storage.remove(["user-1/photo.jpg"]);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Auth
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
// Sign up
|
|
77
|
+
const { user, session } = await linabase.auth.signUp({
|
|
78
|
+
email: "user@example.com",
|
|
79
|
+
password: "securepassword",
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Sign in
|
|
83
|
+
const { user, session } = await linabase.auth.signIn({
|
|
84
|
+
email: "user@example.com",
|
|
85
|
+
password: "securepassword",
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Get current session
|
|
89
|
+
const session = await linabase.auth.getSession();
|
|
90
|
+
|
|
91
|
+
// Sign out
|
|
92
|
+
await linabase.auth.signOut();
|
|
93
|
+
|
|
94
|
+
// Listen for auth changes
|
|
95
|
+
linabase.auth.onAuthStateChange((event, session) => {
|
|
96
|
+
console.log(event, session);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// OAuth
|
|
100
|
+
await linabase.auth.signInWithOAuth({ provider: "google" });
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Schema Selection
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
// Query a different schema (auth, storage, logs)
|
|
107
|
+
const users = await linabase.schema("auth").from("auth_users").select();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## TypeScript
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Generate types from your database schema
|
|
114
|
+
const types = await linabase.generateTypes();
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Service Role (server-side only)
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
const admin = createClient({
|
|
121
|
+
url: "https://your-project.linabase.com",
|
|
122
|
+
serviceRoleKey: "lb_your_service_role_key",
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Bypasses RLS
|
|
126
|
+
const { data } = await admin.from("posts").select();
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Links
|
|
130
|
+
|
|
131
|
+
- [Documentation](https://linabase.com/docs)
|
|
132
|
+
- [GitHub](https://github.com/linabase/linabase)
|
|
133
|
+
- [MCP Server](https://www.npmjs.com/package/@linabase/mcp-server)
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linabase/js",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "JavaScript/TypeScript client SDK for Linabase (database, storage, auth)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
17
18
|
],
|
|
18
19
|
"keywords": [
|
|
19
20
|
"linabase",
|