@kadoa/node-sdk 0.1.0 → 0.1.1
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 +33 -89
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,28 +5,23 @@ Official Node.js/TypeScript SDK for the Kadoa API, providing easy integration wi
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
# CORRECTED: Use @kadoa/node-sdk, not @kadoa/sdk
|
|
9
8
|
npm install @kadoa/node-sdk axios
|
|
10
9
|
# or
|
|
11
10
|
yarn add @kadoa/node-sdk axios
|
|
12
11
|
# or
|
|
13
12
|
pnpm add @kadoa/node-sdk axios
|
|
14
|
-
# or
|
|
15
|
-
bun add @kadoa/node-sdk axios
|
|
16
13
|
```
|
|
17
14
|
|
|
18
|
-
|
|
15
|
+
**Note:** `axios` is required as a peer dependency.
|
|
19
16
|
|
|
20
17
|
## Quick Start
|
|
21
18
|
|
|
22
19
|
```typescript
|
|
23
|
-
// CORRECTED: Use initializeSdk, not initializeApp
|
|
24
20
|
import { initializeSdk, runExtraction } from '@kadoa/node-sdk';
|
|
25
21
|
|
|
26
22
|
// Initialize the SDK
|
|
27
23
|
const sdk = initializeSdk({
|
|
28
|
-
apiKey: 'your-api-key'
|
|
29
|
-
baseUrl: 'https://api.kadoa.com' // optional, defaults to production
|
|
24
|
+
apiKey: 'your-api-key'
|
|
30
25
|
});
|
|
31
26
|
|
|
32
27
|
// Run an extraction
|
|
@@ -42,20 +37,25 @@ if (result) {
|
|
|
42
37
|
|
|
43
38
|
## Configuration
|
|
44
39
|
|
|
45
|
-
|
|
40
|
+
### Basic Configuration
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
const sdk = initializeSdk({
|
|
44
|
+
apiKey: 'your-api-key',
|
|
45
|
+
baseUrl: 'https://api.kadoa.com', // optional
|
|
46
|
+
timeout: 30000 // optional, in ms
|
|
47
|
+
});
|
|
48
|
+
```
|
|
46
49
|
|
|
47
|
-
### Environment Variables
|
|
50
|
+
### Using Environment Variables
|
|
48
51
|
|
|
49
|
-
Create a `.env` file:
|
|
50
52
|
```env
|
|
51
53
|
KADOA_API_KEY=your-api-key
|
|
52
54
|
KADOA_API_URL=https://api.kadoa.com
|
|
53
55
|
KADOA_TIMEOUT=30000
|
|
54
56
|
```
|
|
55
57
|
|
|
56
|
-
Then load them in your code:
|
|
57
58
|
```typescript
|
|
58
|
-
// CORRECTED: Use initializeSdk
|
|
59
59
|
import { initializeSdk } from '@kadoa/node-sdk';
|
|
60
60
|
import { config } from 'dotenv';
|
|
61
61
|
|
|
@@ -63,15 +63,13 @@ config();
|
|
|
63
63
|
|
|
64
64
|
const sdk = initializeSdk({
|
|
65
65
|
apiKey: process.env.KADOA_API_KEY!,
|
|
66
|
-
baseUrl: process.env.KADOA_API_URL
|
|
66
|
+
baseUrl: process.env.KADOA_API_URL,
|
|
67
67
|
timeout: parseInt(process.env.KADOA_TIMEOUT || '30000')
|
|
68
68
|
});
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
## Event Handling
|
|
72
72
|
|
|
73
|
-
The SDK provides event handling capabilities:
|
|
74
|
-
|
|
75
73
|
```typescript
|
|
76
74
|
const sdk = initializeSdk({ apiKey: 'your-api-key' });
|
|
77
75
|
|
|
@@ -80,7 +78,7 @@ sdk.onEvent((event) => {
|
|
|
80
78
|
console.log('Event:', event);
|
|
81
79
|
});
|
|
82
80
|
|
|
83
|
-
//
|
|
81
|
+
// Event types:
|
|
84
82
|
// - entity:detected
|
|
85
83
|
// - extraction:started
|
|
86
84
|
// - extraction:status_changed
|
|
@@ -88,93 +86,39 @@ sdk.onEvent((event) => {
|
|
|
88
86
|
// - extraction:completed
|
|
89
87
|
```
|
|
90
88
|
|
|
91
|
-
##
|
|
92
|
-
|
|
93
|
-
The initialized SDK object contains:
|
|
94
|
-
- `configuration`: Configuration object with API settings
|
|
95
|
-
- `axiosInstance`: Configured Axios HTTP client
|
|
96
|
-
- `baseUrl`: API base URL
|
|
97
|
-
- `events`: Internal event emitter
|
|
98
|
-
- `emit`: Emit custom events
|
|
99
|
-
- `onEvent`: Subscribe to events
|
|
100
|
-
- `offEvent`: Unsubscribe from events
|
|
101
|
-
|
|
102
|
-
## Development
|
|
103
|
-
|
|
104
|
-
### Project Structure
|
|
105
|
-
|
|
106
|
-
```
|
|
107
|
-
sdks/node/
|
|
108
|
-
├── src/
|
|
109
|
-
│ ├── index.ts # Public API exports
|
|
110
|
-
│ ├── app.ts # Application initialization
|
|
111
|
-
│ ├── extraction/ # Extraction module
|
|
112
|
-
│ │ ├── index.ts # Extraction logic
|
|
113
|
-
│ │ └── client.ts # API client helpers
|
|
114
|
-
│ └── generated/ # Auto-generated API client
|
|
115
|
-
├── test/
|
|
116
|
-
│ └── e2e/
|
|
117
|
-
│ └── runExtraction.test.ts
|
|
118
|
-
├── examples/
|
|
119
|
-
│ └── src/
|
|
120
|
-
│ └── run-extraction.ts
|
|
121
|
-
├── package.json
|
|
122
|
-
└── tsup.config.ts
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Running Tests
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
# Run all tests
|
|
129
|
-
npm test
|
|
130
|
-
|
|
131
|
-
# Run E2E tests
|
|
132
|
-
npm run test:e2e
|
|
89
|
+
## API Reference
|
|
133
90
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
### Building
|
|
91
|
+
### initializeSdk(config)
|
|
92
|
+
- `apiKey` (required): Your Kadoa API key
|
|
93
|
+
- `baseUrl` (optional): API base URL
|
|
94
|
+
- `timeout` (optional): Request timeout in milliseconds
|
|
139
95
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
96
|
+
Returns an SDK instance with:
|
|
97
|
+
- `configuration`: Current configuration
|
|
98
|
+
- `axiosInstance`: Configured HTTP client
|
|
99
|
+
- `onEvent()`: Subscribe to events
|
|
100
|
+
- `offEvent()`: Unsubscribe from events
|
|
143
101
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
102
|
+
### runExtraction(sdk, options)
|
|
103
|
+
- `urls`: Array of URLs to extract from
|
|
104
|
+
- `name`: Workflow name
|
|
105
|
+
- Additional options available in API documentation
|
|
147
106
|
|
|
148
|
-
|
|
107
|
+
## Examples
|
|
149
108
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
cd tools/codegen
|
|
154
|
-
bun run generate:node
|
|
155
|
-
```
|
|
109
|
+
See [examples directory](https://github.com/kadoa-org/kadoa-sdks/tree/main/examples/node-examples) for more usage examples.
|
|
156
110
|
|
|
157
111
|
## Requirements
|
|
158
112
|
|
|
159
113
|
- Node.js 18+
|
|
160
114
|
- TypeScript 5+ (for TypeScript projects)
|
|
161
115
|
|
|
162
|
-
## Dependencies
|
|
163
|
-
|
|
164
|
-
- `axios` - HTTP client (must be installed separately)
|
|
165
|
-
- Auto-generated API client code
|
|
166
|
-
|
|
167
|
-
## Known Issues
|
|
168
|
-
|
|
169
|
-
1. **Package Name**: Documentation and npm page incorrectly reference `@kadoa/sdk` instead of `@kadoa/node-sdk`
|
|
170
|
-
2. **Missing Dependency**: The SDK requires `axios` but doesn't declare it as a dependency
|
|
171
|
-
3. **Function Names**: Documentation shows `initializeApp` but the actual export is `initializeSdk`
|
|
172
|
-
4. **Parameter Names**: Documentation refers to "app" object but it's actually an "sdk" object
|
|
173
|
-
|
|
174
116
|
## License
|
|
175
117
|
|
|
176
118
|
MIT
|
|
177
119
|
|
|
178
120
|
## Support
|
|
179
121
|
|
|
180
|
-
|
|
122
|
+
- Documentation: [docs.kadoa.com](https://docs.kadoa.com)
|
|
123
|
+
- Support: [support@kadoa.com](mailto:support@kadoa.com)
|
|
124
|
+
- Issues: [GitHub Issues](https://github.com/kadoa-org/kadoa-sdks/issues)
|