keept-sdk 0.1.0 → 0.1.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 +103 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# keept-sdk
|
|
2
|
+
|
|
3
|
+
Lightweight user data sync SDK — set/get/delete key-value data across Web, App, and plugins in 3 lines of code.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install keept-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { KeeptClient } from 'keept-sdk'
|
|
15
|
+
|
|
16
|
+
const client = new KeeptClient({ baseUrl: 'https://ripple-api.fengwenyi.com/keept' })
|
|
17
|
+
|
|
18
|
+
await client.set('theme', 'dark')
|
|
19
|
+
const theme = await client.get('theme') // 'dark'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
On first use, the SDK automatically registers an account and logs in. Credentials are saved locally (browser: `localStorage`, Node.js: `.keept` file) and reused on subsequent calls. Tokens are refreshed automatically.
|
|
23
|
+
|
|
24
|
+
## API
|
|
25
|
+
|
|
26
|
+
### Initialization
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
const client = new KeeptClient({
|
|
30
|
+
baseUrl: 'https://ripple-api.fengwenyi.com/keept',
|
|
31
|
+
|
|
32
|
+
// Optional: called once after the very first auto-registration.
|
|
33
|
+
// Save these credentials — api_secret will NOT be retrievable again.
|
|
34
|
+
onRegister(apiKey, apiSecret) {
|
|
35
|
+
console.log('api_key :', apiKey)
|
|
36
|
+
console.log('api_secret:', apiSecret)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### KV Methods
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
// Write a value (creates or overwrites)
|
|
45
|
+
await client.set('key', 'value')
|
|
46
|
+
|
|
47
|
+
// Read a value (returns null if not found)
|
|
48
|
+
const value = await client.get('key')
|
|
49
|
+
|
|
50
|
+
// Delete a key (returns true if existed, false otherwise)
|
|
51
|
+
await client.delete('key')
|
|
52
|
+
|
|
53
|
+
// Get all key-value pairs
|
|
54
|
+
const items = await client.getAll()
|
|
55
|
+
// [{ key: 'theme', value: 'dark' }, ...]
|
|
56
|
+
|
|
57
|
+
// Delete all data
|
|
58
|
+
await client.clear()
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Utilities
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
// Get the current api_key (returns null if not yet registered)
|
|
65
|
+
const apiKey = client.getApiKey()
|
|
66
|
+
|
|
67
|
+
// Get usage stats
|
|
68
|
+
const stats = await client.stats()
|
|
69
|
+
// {
|
|
70
|
+
// plan: 'free',
|
|
71
|
+
// monthly_calls: 42,
|
|
72
|
+
// monthly_call_limit: 1000,
|
|
73
|
+
// storage_used: 1024,
|
|
74
|
+
// storage_limit_bytes: 1048576,
|
|
75
|
+
// ...
|
|
76
|
+
// }
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Plans
|
|
80
|
+
|
|
81
|
+
| Plan | Monthly Calls | Storage | Max Value Size | Price |
|
|
82
|
+
|-------|--------------|---------|----------------|--------|
|
|
83
|
+
| Free | 1,000 | 1 MB | 10 KB | $0 |
|
|
84
|
+
| Indie | 100,000 | 100 MB | 100 KB | $9/mo |
|
|
85
|
+
| Pro | 1,000,000 | 1 GB | 1 MB | $29/mo |
|
|
86
|
+
|
|
87
|
+
Free accounts expire after 30 days of inactivity.
|
|
88
|
+
|
|
89
|
+
## Platform Support
|
|
90
|
+
|
|
91
|
+
| Environment | Credential Storage |
|
|
92
|
+
|-------------|-------------------|
|
|
93
|
+
| Browser | `localStorage` |
|
|
94
|
+
| Node.js | `.keept` file |
|
|
95
|
+
| Other | In-memory |
|
|
96
|
+
|
|
97
|
+
## Documentation
|
|
98
|
+
|
|
99
|
+
- [HTTP API 文档](https://github.com/fengwenyi/keept/blob/main/docs/api.md)
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keept-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Lightweight multi-platform user data sync SDK",
|
|
5
5
|
"author": "fengwenyi",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://github.com/fengwenyi/keept
|
|
7
|
+
"homepage": "https://github.com/fengwenyi/keept",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/fengwenyi/keept
|
|
10
|
+
"url": "https://github.com/fengwenyi/keept.git"
|
|
11
11
|
},
|
|
12
12
|
"keywords": ["sync", "kv", "storage", "multiplatform", "keept"],
|
|
13
13
|
"main": "dist/index.js",
|