@kadoa/node-sdk 0.7.0 → 0.9.0
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 +72 -32
- package/dist/index.d.mts +5523 -2263
- package/dist/index.d.ts +5523 -2263
- package/dist/index.js +16419 -1696
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16420 -1698
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -46,12 +46,30 @@ const client = new KadoaClient({
|
|
|
46
46
|
});
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
### Realtime Configuration
|
|
50
|
+
|
|
51
|
+
To enable WebSocket connections for realtime events, use a team API key (starting with `tk-`):
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
const client = new KadoaClient({
|
|
55
|
+
apiKey: 'tk-your-team-api-key', // Must be a team API key
|
|
56
|
+
enableRealtime: true,
|
|
57
|
+
realtimeConfig: {
|
|
58
|
+
autoConnect: true, // optional, default: true
|
|
59
|
+
reconnectDelay: 5000, // optional, default: 5000ms
|
|
60
|
+
heartbeatInterval: 10000 // optional, default: 10000ms
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
49
65
|
### Using Environment Variables
|
|
50
66
|
|
|
51
67
|
```env
|
|
52
68
|
KADOA_API_KEY=your-api-key
|
|
53
|
-
|
|
69
|
+
KADOA_TEAM_API_KEY=tk-your-team-api-key # For realtime features (optional)
|
|
70
|
+
KADOA_PUBLIC_API_URI=https://api.kadoa.com
|
|
54
71
|
KADOA_TIMEOUT=30000
|
|
72
|
+
DEBUG=kadoa:* # Enable all SDK debug logs (optional)
|
|
55
73
|
```
|
|
56
74
|
|
|
57
75
|
```typescript
|
|
@@ -62,7 +80,7 @@ config();
|
|
|
62
80
|
|
|
63
81
|
const client = new KadoaClient({
|
|
64
82
|
apiKey: process.env.KADOA_API_KEY!,
|
|
65
|
-
baseUrl: process.env.
|
|
83
|
+
baseUrl: process.env.KADOA_PUBLIC_API_URI,
|
|
66
84
|
timeout: parseInt(process.env.KADOA_TIMEOUT || '30000')
|
|
67
85
|
});
|
|
68
86
|
```
|
|
@@ -83,38 +101,60 @@ client.onEvent((event) => {
|
|
|
83
101
|
// - extraction:status_changed
|
|
84
102
|
// - extraction:data_available
|
|
85
103
|
// - extraction:completed
|
|
104
|
+
// - realtime:connected (when WebSocket enabled)
|
|
105
|
+
// - realtime:disconnected
|
|
106
|
+
// - realtime:event
|
|
107
|
+
// - realtime:heartbeat
|
|
108
|
+
// - realtime:error
|
|
86
109
|
```
|
|
87
110
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
### Realtime Events
|
|
112
|
+
|
|
113
|
+
When realtime is enabled with a team API key:
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
const client = new KadoaClient({
|
|
117
|
+
apiKey: 'tk-your-team-api-key',
|
|
118
|
+
enableRealtime: true
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Listen to realtime events
|
|
122
|
+
client.onEvent((event) => {
|
|
123
|
+
if (event.type === 'realtime:event') {
|
|
124
|
+
console.log('Received realtime data:', event.payload.data);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Manual connection control
|
|
129
|
+
const realtime = client.connectRealtime();
|
|
130
|
+
|
|
131
|
+
// Check connection status
|
|
132
|
+
if (client.isRealtimeConnected()) {
|
|
133
|
+
console.log('Connected to realtime server');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Disconnect when done
|
|
137
|
+
client.disconnectRealtime();
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Debug Logging
|
|
141
|
+
|
|
142
|
+
The SDK uses the [debug](https://www.npmjs.com/package/debug) package for logging, which is disabled by default. Enable debug logs using the `DEBUG` environment variable:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Enable all Kadoa SDK logs
|
|
146
|
+
DEBUG=kadoa:* node app.js
|
|
147
|
+
|
|
148
|
+
# Enable specific modules
|
|
149
|
+
DEBUG=kadoa:client node app.js # Client operations only
|
|
150
|
+
DEBUG=kadoa:wss node app.js # WebSocket logs only
|
|
151
|
+
DEBUG=kadoa:extraction node app.js # Extraction module logs
|
|
152
|
+
DEBUG=kadoa:http node app.js # HTTP request/response logs
|
|
153
|
+
DEBUG=kadoa:workflow node app.js # Workflow operations
|
|
154
|
+
|
|
155
|
+
# Enable multiple modules
|
|
156
|
+
DEBUG=kadoa:client,kadoa:extraction node app.js
|
|
157
|
+
```
|
|
118
158
|
|
|
119
159
|
## Examples
|
|
120
160
|
|