@kadoa/node-sdk 0.9.0 → 0.11.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 +146 -1
- package/dist/browser/index.global.js +32 -0
- package/dist/browser/index.global.js.map +1 -0
- package/dist/index.d.mts +2351 -4827
- package/dist/index.d.ts +2351 -4827
- package/dist/index.js +2403 -13931
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2402 -13933
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -9
package/README.md
CHANGED
|
@@ -158,7 +158,152 @@ DEBUG=kadoa:client,kadoa:extraction node app.js
|
|
|
158
158
|
|
|
159
159
|
## Examples
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
### Basic Extraction
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
import { KadoaClient } from '@kadoa/node-sdk';
|
|
165
|
+
|
|
166
|
+
const client = new KadoaClient({
|
|
167
|
+
apiKey: 'your-api-key'
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// Run an extraction
|
|
171
|
+
const result = await client.extraction.run({
|
|
172
|
+
urls: ['https://sandbox.kadoa.com/ecommerce'],
|
|
173
|
+
name: 'My Extraction Workflow'
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Fetch paginated data
|
|
177
|
+
if (result.workflowId) {
|
|
178
|
+
const page1 = await client.extraction.fetchData({
|
|
179
|
+
workflowId: result.workflowId,
|
|
180
|
+
page: 1
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
console.log('Data:', page1.data?.slice(0, 5));
|
|
184
|
+
console.log('Pagination:', page1.pagination);
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### WebSocket Events with Notifications
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
// Initialize client with team API key for realtime features
|
|
192
|
+
const client = new KadoaClient({
|
|
193
|
+
apiKey: 'tk-your-team-api-key',
|
|
194
|
+
enableRealtime: true,
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// Listen to realtime events
|
|
198
|
+
client.realtime?.onEvent((event) => {
|
|
199
|
+
console.log('Event received:', event);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// List available notification events
|
|
203
|
+
const availableEvents = await client.notification.settings.listAllEvents();
|
|
204
|
+
|
|
205
|
+
// Run extraction with notifications
|
|
206
|
+
const result = await client.extraction.run({
|
|
207
|
+
urls: ['https://sandbox.kadoa.com/ecommerce'],
|
|
208
|
+
notifications: {
|
|
209
|
+
events: 'all', // or subset of availableEvents
|
|
210
|
+
channels: {
|
|
211
|
+
WEBSOCKET: true,
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Data Validation with Rules
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
import { KadoaClient, pollUntil } from '@kadoa/node-sdk';
|
|
221
|
+
|
|
222
|
+
const client = new KadoaClient({ apiKey: 'your-api-key' });
|
|
223
|
+
|
|
224
|
+
// 1. Run an extraction
|
|
225
|
+
const result = await client.extraction.run({
|
|
226
|
+
urls: ['https://sandbox.kadoa.com/ecommerce'],
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// 2. Wait for automatic rule suggestions
|
|
230
|
+
const rulesResult = await pollUntil(
|
|
231
|
+
async () => await client.validation.listRules({
|
|
232
|
+
workflowId: result.workflowId,
|
|
233
|
+
}),
|
|
234
|
+
(result) => result.data.length > 0,
|
|
235
|
+
{ pollIntervalMs: 1000, timeoutMs: 30000 }
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
// 3. Approve suggested rules
|
|
239
|
+
const approvedRules = await client.validation.bulkApproveRules({
|
|
240
|
+
workflowId: result.workflowId,
|
|
241
|
+
ruleIds: rulesResult.result.data.map(rule => rule.id),
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
// 4. Run validation check
|
|
245
|
+
const validation = await client.validation.scheduleValidation(
|
|
246
|
+
result.workflowId,
|
|
247
|
+
result.workflow?.jobId || ''
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
// 5. Wait for completion and check anomalies
|
|
251
|
+
const completed = await client.validation.waitUntilCompleted(
|
|
252
|
+
validation.validationId
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
const anomalies = await client.validation.getValidationAnomalies(
|
|
256
|
+
validation.validationId
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
console.log('Validation anomalies:', anomalies);
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Complete Example
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
import assert from 'node:assert';
|
|
266
|
+
import { KadoaClient } from '@kadoa/node-sdk';
|
|
267
|
+
|
|
268
|
+
async function main() {
|
|
269
|
+
const apiKey = process.env.KADOA_API_KEY;
|
|
270
|
+
assert(apiKey, 'KADOA_API_KEY is not set');
|
|
271
|
+
|
|
272
|
+
const client = new KadoaClient({ apiKey });
|
|
273
|
+
|
|
274
|
+
// Run extraction
|
|
275
|
+
const result = await client.extraction.run({
|
|
276
|
+
urls: ['https://sandbox.kadoa.com/ecommerce'],
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
// Fetch and display data
|
|
280
|
+
if (result.workflowId) {
|
|
281
|
+
const page1 = await client.extraction.fetchData({
|
|
282
|
+
workflowId: result.workflowId,
|
|
283
|
+
page: 1,
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
console.log('Page 1 Data:');
|
|
287
|
+
console.log('--------------------------------');
|
|
288
|
+
console.log(page1.data?.slice(0, 5));
|
|
289
|
+
console.log(page1.pagination);
|
|
290
|
+
console.log('--------------------------------');
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
console.log('Initial result:', result.data?.slice(0, 5));
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
main().catch(console.error);
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### More Examples
|
|
300
|
+
|
|
301
|
+
See the [examples directory](https://github.com/kadoa-org/kadoa-sdks/tree/main/examples/node-examples) for additional usage examples including:
|
|
302
|
+
- Advanced extraction configurations
|
|
303
|
+
- Custom validation rules
|
|
304
|
+
- Error handling patterns
|
|
305
|
+
- Batch processing
|
|
306
|
+
- Integration patterns
|
|
162
307
|
|
|
163
308
|
## Requirements
|
|
164
309
|
|