udsl-sdk 1.0.0 → 1.0.4
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 +218 -0
- package/cli/index.js +11 -0
- package/cli/installer.js +42 -0
- package/package.json +7 -3
package/README.md
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# UDSL SDK
|
|
2
|
+
|
|
3
|
+
Crash-Safe Data Recovery SDK for JavaScript and TypeScript applications.
|
|
4
|
+
|
|
5
|
+
UDSL (Universal Data Safety Layer) helps applications prevent data loss by using Write-Ahead Logging (WAL), Snapshots, Recovery, Version History, and Rollback mechanisms.
|
|
6
|
+
|
|
7
|
+
## Why UDSL?
|
|
8
|
+
|
|
9
|
+
Applications can lose user data because of:
|
|
10
|
+
|
|
11
|
+
* Application crashes
|
|
12
|
+
* Power failures
|
|
13
|
+
* Unexpected shutdowns
|
|
14
|
+
* Network interruptions
|
|
15
|
+
* Software bugs
|
|
16
|
+
|
|
17
|
+
UDSL provides a recovery layer that ensures user data can be restored even after failures.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
* Write-Ahead Logging (WAL)
|
|
24
|
+
* Snapshot-based recovery
|
|
25
|
+
* Crash recovery
|
|
26
|
+
* Version history
|
|
27
|
+
* Rollback support
|
|
28
|
+
* Multi-tenant architecture
|
|
29
|
+
* API key authentication
|
|
30
|
+
* Offline-first support
|
|
31
|
+
* TypeScript support
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install udsl-sdk
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Initialization
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { UDSL } from "udsl-sdk";
|
|
47
|
+
|
|
48
|
+
UDSL.init({
|
|
49
|
+
baseUrl: "http://localhost:3001",
|
|
50
|
+
apiKey: "your-api-key"
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Save Data
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
await UDSL.save("doc1", {
|
|
60
|
+
title: "Project Notes",
|
|
61
|
+
content: "Building a crash-safe recovery system"
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Read Data
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
const data = await UDSL.get("doc1");
|
|
71
|
+
|
|
72
|
+
console.log(data);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## View History
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const history = await UDSL.history("doc1");
|
|
81
|
+
|
|
82
|
+
console.log(history);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Rollback
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
await UDSL.rollback("doc1", 1);
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This restores the document to version 1.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## How It Works
|
|
98
|
+
|
|
99
|
+
### Step 1
|
|
100
|
+
|
|
101
|
+
Application writes data.
|
|
102
|
+
|
|
103
|
+
```text
|
|
104
|
+
Application
|
|
105
|
+
↓
|
|
106
|
+
UDSL SDK
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Step 2
|
|
110
|
+
|
|
111
|
+
SDK sends data to the recovery engine.
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
SDK
|
|
115
|
+
↓
|
|
116
|
+
Recovery Server
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Step 3
|
|
120
|
+
|
|
121
|
+
Server writes to WAL before acknowledging.
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
Request
|
|
125
|
+
↓
|
|
126
|
+
WAL
|
|
127
|
+
↓
|
|
128
|
+
Snapshot
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Step 4
|
|
132
|
+
|
|
133
|
+
If a crash occurs, recovery rebuilds the latest state.
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
Snapshot
|
|
137
|
+
+
|
|
138
|
+
WAL Replay
|
|
139
|
+
↓
|
|
140
|
+
Recovered State
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Architecture
|
|
146
|
+
|
|
147
|
+
```text
|
|
148
|
+
Application
|
|
149
|
+
↓
|
|
150
|
+
UDSL SDK
|
|
151
|
+
↓
|
|
152
|
+
Recovery API
|
|
153
|
+
↓
|
|
154
|
+
WAL
|
|
155
|
+
Snapshot
|
|
156
|
+
History
|
|
157
|
+
Rollback
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Example Use Cases
|
|
163
|
+
|
|
164
|
+
### Notes Applications
|
|
165
|
+
|
|
166
|
+
Recover user notes after crashes.
|
|
167
|
+
|
|
168
|
+
### Form Builders
|
|
169
|
+
|
|
170
|
+
Prevent loss of partially completed forms.
|
|
171
|
+
|
|
172
|
+
### Code Editors
|
|
173
|
+
|
|
174
|
+
Restore unsaved work automatically.
|
|
175
|
+
|
|
176
|
+
### Enterprise Applications
|
|
177
|
+
|
|
178
|
+
Maintain audit trails and recovery history.
|
|
179
|
+
|
|
180
|
+
### SaaS Platforms
|
|
181
|
+
|
|
182
|
+
Provide reliable data recovery for customers.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Security
|
|
187
|
+
|
|
188
|
+
* API Key Authentication
|
|
189
|
+
* Tenant Isolation
|
|
190
|
+
* Crash-Safe Writes
|
|
191
|
+
* Recovery Validation
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Roadmap
|
|
196
|
+
|
|
197
|
+
* Local Offline Queue
|
|
198
|
+
* Background Sync Engine
|
|
199
|
+
* Data Encryption
|
|
200
|
+
* Cloud Dashboard
|
|
201
|
+
* Analytics
|
|
202
|
+
* Mobile SDK
|
|
203
|
+
* React SDK
|
|
204
|
+
* Automatic Backup System
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## License
|
|
209
|
+
|
|
210
|
+
MIT License
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Author
|
|
215
|
+
|
|
216
|
+
Om Ghadage
|
|
217
|
+
|
|
218
|
+
Building reliable systems that help applications recover data after failures.
|
package/cli/index.js
ADDED
package/cli/installer.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
|
|
3
|
+
function run(cmd) {
|
|
4
|
+
return execSync(cmd, { stdio: "inherit" });
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function start() {
|
|
8
|
+
console.log("🚀 Starting UDSL...");
|
|
9
|
+
|
|
10
|
+
// STEP 1: Check Docker
|
|
11
|
+
try {
|
|
12
|
+
run("docker --version");
|
|
13
|
+
} catch (e) {
|
|
14
|
+
console.log("❌ Docker is not installed");
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// STEP 2: Pull or build image
|
|
19
|
+
try {
|
|
20
|
+
console.log("📦 Pulling UDSL image...");
|
|
21
|
+
run("docker pull udsl-server");
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.log("⚠️ Image not found. Building locally...");
|
|
24
|
+
run("docker build -t udsl-server .");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// STEP 3: Stop old container if exists
|
|
28
|
+
try {
|
|
29
|
+
run("docker stop udsl-server");
|
|
30
|
+
run("docker rm udsl-server");
|
|
31
|
+
} catch (e) {}
|
|
32
|
+
|
|
33
|
+
// STEP 4: Run container
|
|
34
|
+
console.log("🔥 Starting server...");
|
|
35
|
+
run(
|
|
36
|
+
"docker run -d -p 3001:3001 --name udsl-server udsl-server"
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
console.log("✅ UDSL running at http://localhost:3001");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = { start };
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "udsl-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Crash-safe data recovery SDK (WAL + Snapshot based)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
8
|
+
"dist",
|
|
9
|
+
"cli"
|
|
9
10
|
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"udsl": "./cli/index.js"
|
|
13
|
+
},
|
|
10
14
|
"scripts": {
|
|
11
15
|
"build": "tsc",
|
|
12
16
|
"prepublishOnly": "npm run build"
|
|
@@ -24,4 +28,4 @@
|
|
|
24
28
|
"devDependencies": {
|
|
25
29
|
"typescript": "^6.0.3"
|
|
26
30
|
}
|
|
27
|
-
}
|
|
31
|
+
}
|