@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 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,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
- ## API Reference
89
-
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)
94
-
95
- Returns a client instance with:
96
- - `extraction`: Extraction module with `run()`, `submit()`, `fetchData()` methods
97
- - `workflow`: Workflow module with `get()`, `submit()`, `cancel()`, `wait()` methods
98
- - `onEvent()`: Subscribe to events
99
- - `offEvent()`: Unsubscribe from events
100
- - `dispose()`: Releases resources and removes all event listeners
101
-
102
- ### client.extraction.run(options)
103
- Runs extraction and waits for completion.
104
- - `urls`: Array of URLs to extract from
105
- - `name`: Workflow name
106
- - Additional options available in API documentation
107
-
108
- ### client.extraction.submit(options)
109
- Submits extraction without waiting for completion.
110
- - `urls`: Array of URLs to extract from
111
- - `name`: Workflow name
112
- - Returns: `{ workflowId: string }`
113
-
114
- ### client.workflow.get(workflowId)
115
- Gets the current status of a workflow.
116
- - `workflowId`: The workflow ID to query
117
- - Returns: Workflow status object
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