@sockethub/data-layer 1.0.0-alpha.6 → 1.0.0-alpha.7
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/dist/index.js +57881 -0
- package/dist/index.js.map +862 -0
- package/package.json +26 -13
- package/API.md +0 -23
- package/QUEUE.md +0 -130
- package/typedoc.json +0 -11
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sockethub/data-layer",
|
|
3
3
|
"description": "Storing and RPC of data for Sockethub",
|
|
4
|
-
"version": "1.0.0-alpha.
|
|
4
|
+
"version": "1.0.0-alpha.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"author": "Nick Jennings <nick@silverbucket.net>",
|
|
@@ -9,7 +9,18 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
-
"main": "
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"bun": "./src/index.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"src/",
|
|
22
|
+
"dist/"
|
|
23
|
+
],
|
|
13
24
|
"engines": {
|
|
14
25
|
"bun": ">=1.2"
|
|
15
26
|
},
|
|
@@ -28,23 +39,25 @@
|
|
|
28
39
|
},
|
|
29
40
|
"homepage": "https://github.com/sockethub/sockethub/tree/master/packages/data-layer",
|
|
30
41
|
"scripts": {
|
|
42
|
+
"build": "bun build src/index.ts --outdir dist --target node --format esm --sourcemap=external",
|
|
43
|
+
"clean": "rm -rf dist",
|
|
31
44
|
"doc": "typedoc --options typedoc.json"
|
|
32
45
|
},
|
|
33
46
|
"dependencies": {
|
|
34
|
-
"@sockethub/crypto": "1.0.0-alpha.
|
|
35
|
-
"@sockethub/schemas": "3.0.0-alpha.
|
|
36
|
-
"bullmq": "5.66.
|
|
37
|
-
"debug": "4.3
|
|
38
|
-
"ioredis": "5.
|
|
39
|
-
"secure-store-redis": "3.0.7"
|
|
47
|
+
"@sockethub/crypto": "^1.0.0-alpha.7",
|
|
48
|
+
"@sockethub/schemas": "^3.0.0-alpha.7",
|
|
49
|
+
"bullmq": "^5.66.5",
|
|
50
|
+
"debug": "^4.4.3",
|
|
51
|
+
"ioredis": "^5.9.2",
|
|
52
|
+
"secure-store-redis": "^3.0.7"
|
|
40
53
|
},
|
|
41
54
|
"devDependencies": {
|
|
42
55
|
"@types/bun": "latest",
|
|
43
|
-
"@types/debug": "4.1.12",
|
|
44
|
-
"@types/sinon": "17.0.
|
|
45
|
-
"sinon": "17.0.
|
|
46
|
-
"typedoc": "^0.28.
|
|
56
|
+
"@types/debug": "^4.1.12",
|
|
57
|
+
"@types/sinon": "^17.0.4",
|
|
58
|
+
"sinon": "^17.0.2",
|
|
59
|
+
"typedoc": "^0.28.16",
|
|
47
60
|
"typedoc-plugin-markdown": "^4.9.0"
|
|
48
61
|
},
|
|
49
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "38927776c210a22bc54ceb86ccc7276c5f27b463"
|
|
50
63
|
}
|
package/API.md
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# API Documentation
|
|
2
|
-
|
|
3
|
-
This package provides the data layer for Sockethub, including job queue management and secure credential storage.
|
|
4
|
-
|
|
5
|
-
## Main Classes
|
|
6
|
-
|
|
7
|
-
### JobQueue
|
|
8
|
-
Redis-backed job queue for managing ActivityStreams message processing. Creates isolated queues per platform instance and session, providing reliable message delivery and processing coordination between Sockethub server and platform workers.
|
|
9
|
-
|
|
10
|
-
### JobWorker
|
|
11
|
-
Worker for processing jobs from a Redis queue within platform child processes. Connects to the same queue as its corresponding JobQueue instance and processes jobs using a platform-specific handler function.
|
|
12
|
-
|
|
13
|
-
### CredentialsStore
|
|
14
|
-
Secure, encrypted storage for user credentials with session-based isolation. Provides automatic encryption/decryption of credential objects stored in Redis, ensuring that sensitive authentication data is never stored in plaintext.
|
|
15
|
-
|
|
16
|
-
## Complete API Reference
|
|
17
|
-
|
|
18
|
-
For detailed API documentation including method signatures, parameters, and examples, see the [generated TypeDoc documentation](./docs/index.html).
|
|
19
|
-
|
|
20
|
-
## Related Documentation
|
|
21
|
-
|
|
22
|
-
- [Queue Architecture](./QUEUE.md) - Conceptual overview of the queueing system
|
|
23
|
-
- [Main Sockethub Documentation](https://github.com/sockethub/sockethub)
|
package/QUEUE.md
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
# Sockethub Queue System
|
|
2
|
-
|
|
3
|
-
The queue system is Sockethub's core infrastructure that enables reliable, scalable
|
|
4
|
-
communication between web clients and protocol platforms.
|
|
5
|
-
|
|
6
|
-
## Why a Queue System?
|
|
7
|
-
|
|
8
|
-
Web applications need to communicate with network protocols (IRC, XMPP, RSS) that:
|
|
9
|
-
|
|
10
|
-
- Have slow or unreliable connections
|
|
11
|
-
- Require persistent state that browsers can't maintain
|
|
12
|
-
- Need to operate across multiple concurrent user sessions
|
|
13
|
-
|
|
14
|
-
The queue system solves this by:
|
|
15
|
-
|
|
16
|
-
- **Decoupling** web clients from protocol complexity
|
|
17
|
-
- **Ensuring reliability** through message persistence
|
|
18
|
-
- **Enabling concurrency** via process isolation
|
|
19
|
-
- **Maintaining security** through encrypted message handling
|
|
20
|
-
|
|
21
|
-
## Architecture Overview
|
|
22
|
-
|
|
23
|
-
```
|
|
24
|
-
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
|
25
|
-
│ Web Clients │ │ Sockethub │ │ Protocol │
|
|
26
|
-
│ │ │ Queue System │ │ Platforms │
|
|
27
|
-
│ • Browser Apps │◄──►│ │◄──►│ │
|
|
28
|
-
│ • Mobile Apps │ │ • Job Queues │ │ • IRC Client │
|
|
29
|
-
│ • Desktop Apps │ │ • Message │ │ • XMPP Client │
|
|
30
|
-
│ • APIs │ │ Routing │ │ • RSS Parser │
|
|
31
|
-
│ │ │ • Session Mgmt │ │ • Metadata │
|
|
32
|
-
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Message Flow
|
|
36
|
-
|
|
37
|
-
### 1. Web Request → Queue
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
Web App → Socket.IO → Sockethub Server → Redis Queue
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
- Client sends ActivityStreams message
|
|
44
|
-
- Server validates and queues the request
|
|
45
|
-
- Client gets immediate acknowledgment
|
|
46
|
-
|
|
47
|
-
### 2. Queue → Platform Processing
|
|
48
|
-
|
|
49
|
-
```
|
|
50
|
-
Redis Queue → Platform Worker → External Protocol → Response
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
- Platform worker picks up job
|
|
54
|
-
- Processes protocol-specific logic in isolation
|
|
55
|
-
- Connects to external services (IRC, XMPP, etc.)
|
|
56
|
-
|
|
57
|
-
### 3. Response → Client
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
Platform Result → Queue Event → Sockethub Server → Socket.IO → Web App
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
- Results flow back through the queue
|
|
64
|
-
- Real-time updates delivered via Socket.IO
|
|
65
|
-
- Clients receive responses and ongoing events
|
|
66
|
-
|
|
67
|
-
## Key Design Principles
|
|
68
|
-
|
|
69
|
-
**Process Isolation**: Each protocol runs in its own child process
|
|
70
|
-
|
|
71
|
-
- Crashed platforms don't affect others
|
|
72
|
-
- Memory leaks and resource issues are contained
|
|
73
|
-
- Different platforms can use different dependencies
|
|
74
|
-
|
|
75
|
-
**Session-Based Queues**: Each client gets dedicated queue infrastructure
|
|
76
|
-
|
|
77
|
-
- Complete privacy between users
|
|
78
|
-
- Natural load distribution
|
|
79
|
-
- Session-specific configurations possible
|
|
80
|
-
|
|
81
|
-
**Message Durability**: All messages persist until processed
|
|
82
|
-
|
|
83
|
-
- Server restarts don't lose messages
|
|
84
|
-
- Failed operations can be retried
|
|
85
|
-
- Audit trail for debugging
|
|
86
|
-
|
|
87
|
-
## Real-World Example
|
|
88
|
-
|
|
89
|
-
A chat application connecting to both IRC and XMPP:
|
|
90
|
-
|
|
91
|
-
```
|
|
92
|
-
User message → Queue → [IRC Platform] + [XMPP Platform]
|
|
93
|
-
↓ ↓
|
|
94
|
-
IRC Network XMPP Network
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**Benefits:**
|
|
98
|
-
|
|
99
|
-
- Both protocols process concurrently
|
|
100
|
-
- Slow IRC doesn't block XMPP messages
|
|
101
|
-
- Platform crashes only affect that protocol
|
|
102
|
-
- Independent delivery confirmations
|
|
103
|
-
|
|
104
|
-
## Operational Characteristics
|
|
105
|
-
|
|
106
|
-
**Reliability**: Messages are never lost, even during:
|
|
107
|
-
|
|
108
|
-
- Server restarts
|
|
109
|
-
- Platform process crashes
|
|
110
|
-
- Temporary network failures
|
|
111
|
-
- Redis downtime
|
|
112
|
-
|
|
113
|
-
**Scalability**: Natural horizontal scaling:
|
|
114
|
-
|
|
115
|
-
- Multiple server instances share Redis
|
|
116
|
-
- Per-session queue isolation
|
|
117
|
-
- No coordination between servers required
|
|
118
|
-
|
|
119
|
-
**Performance**: Asynchronous design provides:
|
|
120
|
-
|
|
121
|
-
- Immediate web request responses
|
|
122
|
-
- Concurrent protocol processing
|
|
123
|
-
- Efficient resource utilization
|
|
124
|
-
|
|
125
|
-
## Related Documentation
|
|
126
|
-
|
|
127
|
-
- [Data Layer Package README](README.md) - Package overview and usage
|
|
128
|
-
- [Main Sockethub README](../../README.md) - Overall project documentation
|
|
129
|
-
- [BullMQ Documentation](https://bullmq.io/) - Underlying queue library
|
|
130
|
-
- [ActivityStreams Specification](https://www.w3.org/TR/activitystreams-core/) - Message format standard
|
package/typedoc.json
DELETED