@luxdb/sdk 1.4.1 → 1.4.2

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 ADDED
@@ -0,0 +1,132 @@
1
+ # @luxdb/sdk
2
+
3
+ Official TypeScript SDK for Lux.
4
+
5
+ Use the project client for browser, server, and SSR app code. Use the direct client when you want low-level Redis-compatible access to a Lux instance.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ bun i @luxdb/sdk
11
+ ```
12
+
13
+ ## Browser app client
14
+
15
+ Use a publishable key in browser code. The browser client persists auth sessions in browser storage by default.
16
+
17
+ ```ts
18
+ import { createBrowserClient } from "@luxdb/sdk";
19
+
20
+ const lux = createBrowserClient(
21
+ "https://api.luxdb.dev/v1/my-project",
22
+ "lux_pub_..."
23
+ );
24
+
25
+ const { data: session, error } = await lux.auth.signInWithPassword({
26
+ email: "user@example.com",
27
+ password: "correct horse battery staple",
28
+ });
29
+
30
+ if (error) throw error;
31
+ ```
32
+
33
+ ## Tables
34
+
35
+ Queries and mutations return a Supabase-style result object:
36
+
37
+ ```ts
38
+ const { data: users, error } = await lux
39
+ .table<{ id: number; email: string; age: number }>("users")
40
+ .select()
41
+ .gt("age", 25)
42
+ .order("age", { ascending: false })
43
+ .limit(10);
44
+
45
+ if (error) throw error;
46
+ console.log(users);
47
+ ```
48
+
49
+ ```ts
50
+ const { data: inserted, error: insertError } = await lux
51
+ .table("messages")
52
+ .insert({ body: "hello", channel: "general" });
53
+
54
+ const { data: updated, error: updateError } = await lux
55
+ .table("messages")
56
+ .update({ body: "edited" })
57
+ .eq("id", inserted?.id);
58
+
59
+ const { data: deleted, error: deleteError } = await lux
60
+ .table("messages")
61
+ .delete()
62
+ .eq("id", inserted?.id);
63
+ ```
64
+
65
+ ## OAuth
66
+
67
+ ```ts
68
+ const { data, error } = await lux.auth.signInWithOAuth({
69
+ provider: "google",
70
+ redirectTo: "https://app.example.com/auth/callback",
71
+ });
72
+
73
+ if (error) throw error;
74
+ ```
75
+
76
+ On your callback page:
77
+
78
+ ```ts
79
+ const { data, error } = await lux.auth.consumeOAuthRedirect();
80
+
81
+ if (error) throw error;
82
+ console.log(data.user);
83
+ ```
84
+
85
+ ## Server client
86
+
87
+ Use a secret key only from trusted server code.
88
+
89
+ ```ts
90
+ import { createClient } from "@luxdb/sdk";
91
+
92
+ const admin = createClient(
93
+ "https://api.luxdb.dev/v1/my-project",
94
+ process.env.LUX_SECRET_KEY!
95
+ );
96
+
97
+ const { data: users, error } = await admin.auth.listUsers();
98
+ ```
99
+
100
+ ## SSR client
101
+
102
+ Use `createServerClient` with your framework's cookie methods to persist sessions on the server.
103
+
104
+ ```ts
105
+ import { createServerClient } from "@luxdb/sdk";
106
+
107
+ const lux = createServerClient(
108
+ "https://api.luxdb.dev/v1/my-project",
109
+ "lux_pub_...",
110
+ { cookies }
111
+ );
112
+ ```
113
+
114
+ ## Direct Lux/Redis-compatible access
115
+
116
+ Use direct access for trusted infrastructure that needs RESP commands, low-level primitives, or compatibility with Redis workflows. Do not ship database passwords to browsers.
117
+
118
+ ```ts
119
+ import Lux from "@luxdb/sdk";
120
+
121
+ const lux = new Lux("lux://:password@localhost:6379");
122
+
123
+ await lux.set("hello", "world");
124
+ const value = await lux.get("hello");
125
+ ```
126
+
127
+ ## Access model
128
+
129
+ - `lux_pub_...` keys are safe for browser app calls.
130
+ - `lux_sec_...` keys are server-only.
131
+ - User sessions issue JWT access tokens.
132
+ - Direct `lux://` or `rediss://` database access uses the database password and is for trusted infrastructure.
package/dist/cjs/index.js CHANGED
@@ -44,10 +44,7 @@ class Lux extends ioredis_1.default {
44
44
  constructor(options) {
45
45
  let authOptions = {};
46
46
  if (typeof options === 'string') {
47
- if (options.startsWith('rediss://') || options.startsWith('luxs://')) {
48
- throw new Error('TLS is not yet supported');
49
- }
50
- options = options.replace(/^lux:\/\//, 'redis://');
47
+ options = options.replace(/^luxs:\/\//, 'rediss://').replace(/^lux:\/\//, 'redis://');
51
48
  }
52
49
  else if (options) {
53
50
  const { httpUrl, apiKey, authToken, fetch: fetchImpl, ...redisOptions } = options;
package/dist/esm/index.js CHANGED
@@ -31,10 +31,7 @@ export class Lux extends Redis {
31
31
  constructor(options) {
32
32
  let authOptions = {};
33
33
  if (typeof options === 'string') {
34
- if (options.startsWith('rediss://') || options.startsWith('luxs://')) {
35
- throw new Error('TLS is not yet supported');
36
- }
37
- options = options.replace(/^lux:\/\//, 'redis://');
34
+ options = options.replace(/^luxs:\/\//, 'rediss://').replace(/^lux:\/\//, 'redis://');
38
35
  }
39
36
  else if (options) {
40
37
  const { httpUrl, apiKey, authToken, fetch: fetchImpl, ...redisOptions } = options;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@luxdb/sdk",
3
- "version": "1.4.1",
4
- "description": "Lux SDK - ioredis extended with vector search, time series, and realtime key subscriptions",
3
+ "version": "1.4.2",
4
+ "description": "Official Lux TypeScript SDK for app data, auth, tables, vectors, realtime, and Redis-compatible direct access",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
7
7
  "types": "./dist/types/index.d.ts",
@@ -59,5 +59,5 @@
59
59
  "url": "https://github.com/lux-db/lux",
60
60
  "directory": "sdk"
61
61
  },
62
- "keywords": ["lux", "redis", "vector", "search", "database", "ioredis", "similarity", "timeseries", "realtime", "subscriptions"]
62
+ "keywords": ["lux", "database", "application-database", "auth", "tables", "vectors", "realtime", "redis", "cache", "queues", "timeseries"]
63
63
  }