@kadoa/node-sdk 0.5.1 → 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 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
- KADOA_API_URL=https://api.kadoa.com
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.KADOA_API_URL,
83
+ baseUrl: process.env.KADOA_PUBLIC_API_URI,
66
84
  timeout: parseInt(process.env.KADOA_TIMEOUT || '30000')
67
85
  });
68
86
  ```
@@ -83,25 +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
- ## API Reference
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
+ });
89
127
 
90
- ### new KadoaClient(config)
91
- - `apiKey` (required): Your Kadoa API key
92
- - `baseUrl` (optional): API base URL (default: 'https://api.kadoa.com')
93
- - `timeout` (optional): Request timeout in milliseconds (default: 30000)
128
+ // Manual connection control
129
+ const realtime = client.connectRealtime();
94
130
 
95
- Returns a client instance with:
96
- - `extraction`: Extraction module with `run()` method
97
- - `onEvent()`: Subscribe to events
98
- - `offEvent()`: Unsubscribe from events
99
- - `dispose()`: Releases resources and removes all event listeners
131
+ // Check connection status
132
+ if (client.isRealtimeConnected()) {
133
+ console.log('Connected to realtime server');
134
+ }
100
135
 
101
- ### client.extraction.run(options)
102
- - `urls`: Array of URLs to extract from
103
- - `name`: Workflow name
104
- - Additional options available in API documentation
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
+ ```
105
158
 
106
159
  ## Examples
107
160