@kadoa/node-sdk 0.0.2 → 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 +54 -67
- package/dist/index.d.mts +171 -164
- package/dist/index.d.ts +171 -164
- package/dist/index.js +394 -368
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +394 -368
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -5,28 +5,27 @@ Official Node.js/TypeScript SDK for the Kadoa API, providing easy integration wi
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @kadoa/sdk
|
|
8
|
+
npm install @kadoa/node-sdk axios
|
|
9
9
|
# or
|
|
10
|
-
yarn add @kadoa/sdk
|
|
10
|
+
yarn add @kadoa/node-sdk axios
|
|
11
11
|
# or
|
|
12
|
-
pnpm add @kadoa/sdk
|
|
13
|
-
# or
|
|
14
|
-
bun add @kadoa/sdk
|
|
12
|
+
pnpm add @kadoa/node-sdk axios
|
|
15
13
|
```
|
|
16
14
|
|
|
15
|
+
**Note:** `axios` is required as a peer dependency.
|
|
16
|
+
|
|
17
17
|
## Quick Start
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
|
-
import {
|
|
20
|
+
import { initializeSdk, runExtraction } from '@kadoa/node-sdk';
|
|
21
21
|
|
|
22
22
|
// Initialize the SDK
|
|
23
|
-
const
|
|
24
|
-
apiKey: 'your-api-key'
|
|
25
|
-
baseUrl: 'https://api.kadoa.com' // optional, defaults to production
|
|
23
|
+
const sdk = initializeSdk({
|
|
24
|
+
apiKey: 'your-api-key'
|
|
26
25
|
});
|
|
27
26
|
|
|
28
27
|
// Run an extraction
|
|
29
|
-
const result = await runExtraction(
|
|
28
|
+
const result = await runExtraction(sdk, {
|
|
30
29
|
urls: ['https://example.com'],
|
|
31
30
|
name: 'My Extraction Workflow'
|
|
32
31
|
});
|
|
@@ -38,100 +37,88 @@ if (result) {
|
|
|
38
37
|
|
|
39
38
|
## Configuration
|
|
40
39
|
|
|
41
|
-
|
|
40
|
+
### Basic Configuration
|
|
42
41
|
|
|
43
|
-
|
|
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
|
+
```
|
|
49
|
+
|
|
50
|
+
### Using Environment Variables
|
|
44
51
|
|
|
45
|
-
Create a `.env` file:
|
|
46
52
|
```env
|
|
47
53
|
KADOA_API_KEY=your-api-key
|
|
48
54
|
KADOA_API_URL=https://api.kadoa.com
|
|
49
55
|
KADOA_TIMEOUT=30000
|
|
50
56
|
```
|
|
51
57
|
|
|
52
|
-
Then load them in your code:
|
|
53
58
|
```typescript
|
|
54
|
-
import {
|
|
59
|
+
import { initializeSdk } from '@kadoa/node-sdk';
|
|
55
60
|
import { config } from 'dotenv';
|
|
56
61
|
|
|
57
62
|
config();
|
|
58
63
|
|
|
59
|
-
const
|
|
64
|
+
const sdk = initializeSdk({
|
|
60
65
|
apiKey: process.env.KADOA_API_KEY!,
|
|
61
|
-
baseUrl: process.env.KADOA_API_URL
|
|
66
|
+
baseUrl: process.env.KADOA_API_URL,
|
|
62
67
|
timeout: parseInt(process.env.KADOA_TIMEOUT || '30000')
|
|
63
68
|
});
|
|
64
69
|
```
|
|
65
70
|
|
|
66
|
-
##
|
|
67
|
-
|
|
68
|
-
### Project Structure
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
sdks/node/
|
|
72
|
-
├── src/
|
|
73
|
-
│ ├── index.ts # Public API exports
|
|
74
|
-
│ ├── app.ts # Application initialization
|
|
75
|
-
│ ├── extraction/ # Extraction module
|
|
76
|
-
│ │ ├── index.ts # Extraction logic
|
|
77
|
-
│ │ └── client.ts # API client helpers
|
|
78
|
-
│ └── generated/ # Auto-generated API client
|
|
79
|
-
├── test/
|
|
80
|
-
│ └── e2e/
|
|
81
|
-
│ └── runExtraction.test.ts
|
|
82
|
-
├── examples/
|
|
83
|
-
│ └── src/
|
|
84
|
-
│ └── run-extraction.ts
|
|
85
|
-
├── package.json
|
|
86
|
-
└── tsup.config.ts
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Running Tests
|
|
71
|
+
## Event Handling
|
|
90
72
|
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
npm test
|
|
73
|
+
```typescript
|
|
74
|
+
const sdk = initializeSdk({ apiKey: 'your-api-key' });
|
|
94
75
|
|
|
95
|
-
|
|
96
|
-
|
|
76
|
+
// Listen to events
|
|
77
|
+
sdk.onEvent((event) => {
|
|
78
|
+
console.log('Event:', event);
|
|
79
|
+
});
|
|
97
80
|
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
// Event types:
|
|
82
|
+
// - entity:detected
|
|
83
|
+
// - extraction:started
|
|
84
|
+
// - extraction:status_changed
|
|
85
|
+
// - extraction:data_available
|
|
86
|
+
// - extraction:completed
|
|
100
87
|
```
|
|
101
88
|
|
|
102
|
-
|
|
89
|
+
## API Reference
|
|
103
90
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
### initializeSdk(config)
|
|
92
|
+
- `apiKey` (required): Your Kadoa API key
|
|
93
|
+
- `baseUrl` (optional): API base URL
|
|
94
|
+
- `timeout` (optional): Request timeout in milliseconds
|
|
107
95
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
|
111
101
|
|
|
112
|
-
###
|
|
102
|
+
### runExtraction(sdk, options)
|
|
103
|
+
- `urls`: Array of URLs to extract from
|
|
104
|
+
- `name`: Workflow name
|
|
105
|
+
- Additional options available in API documentation
|
|
113
106
|
|
|
114
|
-
|
|
107
|
+
## Examples
|
|
115
108
|
|
|
116
|
-
|
|
117
|
-
cd tools/codegen
|
|
118
|
-
bun run generate:node
|
|
119
|
-
```
|
|
109
|
+
See [examples directory](https://github.com/kadoa-org/kadoa-sdks/tree/main/examples/node-examples) for more usage examples.
|
|
120
110
|
|
|
121
111
|
## Requirements
|
|
122
112
|
|
|
123
113
|
- Node.js 18+
|
|
124
114
|
- TypeScript 5+ (for TypeScript projects)
|
|
125
115
|
|
|
126
|
-
## Dependencies
|
|
127
|
-
|
|
128
|
-
- `axios` - HTTP client
|
|
129
|
-
- Auto-generated API client code
|
|
130
|
-
|
|
131
116
|
## License
|
|
132
117
|
|
|
133
118
|
MIT
|
|
134
119
|
|
|
135
120
|
## Support
|
|
136
121
|
|
|
137
|
-
|
|
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)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,157 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosError } from 'axios';
|
|
2
1
|
import { EventEmitter } from 'events';
|
|
2
|
+
import { AxiosError, AxiosInstance } from 'axios';
|
|
3
|
+
|
|
4
|
+
type EntityEventPayloads = {
|
|
5
|
+
"entity:detected": {
|
|
6
|
+
/** Name of the detected entity type (e.g., "Product", "Article", "Job Listing") */
|
|
7
|
+
entity: string;
|
|
8
|
+
/** Data fields detected for the entity */
|
|
9
|
+
fields: Array<{
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
example: string;
|
|
13
|
+
dataType: string | Record<string, unknown>;
|
|
14
|
+
isPrimaryKey?: boolean;
|
|
15
|
+
}>;
|
|
16
|
+
/** URL that was analyzed for entity detection */
|
|
17
|
+
url: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
type ExtractionEventPayloads = {
|
|
21
|
+
"extraction:started": {
|
|
22
|
+
/** Unique ID of the extraction process */
|
|
23
|
+
workflowId: string;
|
|
24
|
+
/** Name given to this extraction */
|
|
25
|
+
name: string;
|
|
26
|
+
/** URLs to extract data from */
|
|
27
|
+
urls: string[];
|
|
28
|
+
};
|
|
29
|
+
"extraction:status_changed": {
|
|
30
|
+
/** Unique ID of the extraction process */
|
|
31
|
+
workflowId: string;
|
|
32
|
+
/** Previous processing state */
|
|
33
|
+
previousState?: string;
|
|
34
|
+
/** Previous execution status */
|
|
35
|
+
previousRunState?: string;
|
|
36
|
+
/** Current processing state */
|
|
37
|
+
currentState?: string;
|
|
38
|
+
/** Current execution status */
|
|
39
|
+
currentRunState?: string;
|
|
40
|
+
};
|
|
41
|
+
"extraction:data_available": {
|
|
42
|
+
/** Unique ID of the extraction process */
|
|
43
|
+
workflowId: string;
|
|
44
|
+
/** Number of data records retrieved */
|
|
45
|
+
recordCount: number;
|
|
46
|
+
/** Whether this is a partial data set */
|
|
47
|
+
isPartial: boolean;
|
|
48
|
+
};
|
|
49
|
+
"extraction:completed": {
|
|
50
|
+
/** Unique ID of the extraction process */
|
|
51
|
+
workflowId: string;
|
|
52
|
+
/** Whether the extraction completed successfully */
|
|
53
|
+
success: boolean;
|
|
54
|
+
/** Final execution status */
|
|
55
|
+
finalRunState?: string;
|
|
56
|
+
/** Final processing state */
|
|
57
|
+
finalState?: string;
|
|
58
|
+
/** Number of records extracted (if successful) */
|
|
59
|
+
recordCount?: number;
|
|
60
|
+
/** Error message (if failed) */
|
|
61
|
+
error?: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
type EventPayloadMap = EntityEventPayloads & ExtractionEventPayloads;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Unified event structure with discriminated union
|
|
68
|
+
*/
|
|
69
|
+
interface KadoaEvent<T extends keyof EventPayloadMap = keyof EventPayloadMap> {
|
|
70
|
+
/** Event type identifier */
|
|
71
|
+
type: T;
|
|
72
|
+
/** ISO timestamp when the event occurred */
|
|
73
|
+
timestamp: Date;
|
|
74
|
+
/** Module or component that emitted the event */
|
|
75
|
+
source: string;
|
|
76
|
+
/** Event-specific payload */
|
|
77
|
+
payload: EventPayloadMap[T];
|
|
78
|
+
/** Optional metadata for debugging and tracking */
|
|
79
|
+
metadata?: Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Type aliases for convenience
|
|
83
|
+
*/
|
|
84
|
+
type KadoaEventName = keyof EventPayloadMap;
|
|
85
|
+
type AnyKadoaEvent = KadoaEvent<KadoaEventName>;
|
|
86
|
+
/**
|
|
87
|
+
* Simplified type-safe event emitter for Kadoa SDK events
|
|
88
|
+
*/
|
|
89
|
+
declare class KadoaEventEmitter extends EventEmitter {
|
|
90
|
+
/**
|
|
91
|
+
* Emit a typed SDK event
|
|
92
|
+
*/
|
|
93
|
+
emit<T extends KadoaEventName>(eventName: T, payload: EventPayloadMap[T], source?: string, metadata?: Record<string, unknown>): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Subscribe to SDK events
|
|
96
|
+
*/
|
|
97
|
+
onEvent(listener: (event: AnyKadoaEvent) => void): this;
|
|
98
|
+
/**
|
|
99
|
+
* Subscribe to SDK events (once)
|
|
100
|
+
*/
|
|
101
|
+
onceEvent(listener: (event: AnyKadoaEvent) => void): this;
|
|
102
|
+
/**
|
|
103
|
+
* Unsubscribe from SDK events
|
|
104
|
+
*/
|
|
105
|
+
offEvent(listener: (event: AnyKadoaEvent) => void): this;
|
|
106
|
+
/**
|
|
107
|
+
* Remove all event listeners
|
|
108
|
+
*/
|
|
109
|
+
removeAllEventListeners(): this;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
type KadoaErrorCode = "UNKNOWN" | "CONFIG_ERROR" | "AUTH_ERROR" | "VALIDATION_ERROR" | "NOT_FOUND" | "RATE_LIMITED" | "TIMEOUT" | "NETWORK_ERROR" | "HTTP_ERROR" | "INTERNAL_ERROR";
|
|
113
|
+
type KadoaSdkExceptionOptions = {
|
|
114
|
+
code?: KadoaErrorCode;
|
|
115
|
+
details?: Record<string, unknown>;
|
|
116
|
+
cause?: unknown;
|
|
117
|
+
};
|
|
118
|
+
declare class KadoaSdkException extends Error {
|
|
119
|
+
readonly code: KadoaErrorCode;
|
|
120
|
+
readonly details?: Record<string, unknown>;
|
|
121
|
+
readonly cause?: unknown;
|
|
122
|
+
constructor(message: string, options?: KadoaSdkExceptionOptions);
|
|
123
|
+
static from(error: unknown, details?: Record<string, unknown>): KadoaSdkException;
|
|
124
|
+
toJSON(): Record<string, unknown>;
|
|
125
|
+
toString(): string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
type KadoaHttpExceptionOptions = {
|
|
129
|
+
httpStatus?: number;
|
|
130
|
+
requestId?: string;
|
|
131
|
+
endpoint?: string;
|
|
132
|
+
method?: string;
|
|
133
|
+
responseBody?: unknown;
|
|
134
|
+
details?: Record<string, unknown>;
|
|
135
|
+
code?: KadoaErrorCode;
|
|
136
|
+
cause?: unknown;
|
|
137
|
+
};
|
|
138
|
+
declare class KadoaHttpException extends KadoaSdkException {
|
|
139
|
+
readonly httpStatus?: number;
|
|
140
|
+
readonly requestId?: string;
|
|
141
|
+
readonly endpoint?: string;
|
|
142
|
+
readonly method?: string;
|
|
143
|
+
readonly responseBody?: unknown;
|
|
144
|
+
constructor(message: string, options?: KadoaHttpExceptionOptions);
|
|
145
|
+
static fromAxiosError(error: AxiosError, extra?: {
|
|
146
|
+
message?: string;
|
|
147
|
+
details?: Record<string, unknown>;
|
|
148
|
+
}): KadoaHttpException;
|
|
149
|
+
toJSON(): Record<string, unknown>;
|
|
150
|
+
private static mapStatusToCode;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare function isKadoaSdkException(error: unknown): error is KadoaSdkException;
|
|
154
|
+
declare function isKadoaHttpException(error: unknown): error is KadoaHttpException;
|
|
3
155
|
|
|
4
156
|
/**
|
|
5
157
|
* Kadoa API
|
|
@@ -660,115 +812,6 @@ declare const V4WorkflowsWorkflowIdGet200ResponseSchemaTypeEnum: {
|
|
|
660
812
|
};
|
|
661
813
|
type V4WorkflowsWorkflowIdGet200ResponseSchemaTypeEnum = typeof V4WorkflowsWorkflowIdGet200ResponseSchemaTypeEnum[keyof typeof V4WorkflowsWorkflowIdGet200ResponseSchemaTypeEnum];
|
|
662
814
|
|
|
663
|
-
type EntityEventPayloads = {
|
|
664
|
-
"entity:detected": {
|
|
665
|
-
/** Name of the detected entity type (e.g., "Product", "Article", "Job Listing") */
|
|
666
|
-
entity: string;
|
|
667
|
-
/** Data fields detected for the entity */
|
|
668
|
-
fields: Array<{
|
|
669
|
-
name: string;
|
|
670
|
-
description: string;
|
|
671
|
-
example: string;
|
|
672
|
-
dataType: string | Record<string, unknown>;
|
|
673
|
-
isPrimaryKey?: boolean;
|
|
674
|
-
}>;
|
|
675
|
-
/** URL that was analyzed for entity detection */
|
|
676
|
-
url: string;
|
|
677
|
-
};
|
|
678
|
-
};
|
|
679
|
-
type ExtractionEventPayloads = {
|
|
680
|
-
"extraction:started": {
|
|
681
|
-
/** Unique ID of the extraction process */
|
|
682
|
-
workflowId: string;
|
|
683
|
-
/** Name given to this extraction */
|
|
684
|
-
name: string;
|
|
685
|
-
/** URLs to extract data from */
|
|
686
|
-
urls: string[];
|
|
687
|
-
};
|
|
688
|
-
"extraction:status_changed": {
|
|
689
|
-
/** Unique ID of the extraction process */
|
|
690
|
-
workflowId: string;
|
|
691
|
-
/** Previous processing state */
|
|
692
|
-
previousState?: string;
|
|
693
|
-
/** Previous execution status */
|
|
694
|
-
previousRunState?: string;
|
|
695
|
-
/** Current processing state */
|
|
696
|
-
currentState?: string;
|
|
697
|
-
/** Current execution status */
|
|
698
|
-
currentRunState?: string;
|
|
699
|
-
};
|
|
700
|
-
"extraction:data_available": {
|
|
701
|
-
/** Unique ID of the extraction process */
|
|
702
|
-
workflowId: string;
|
|
703
|
-
/** Number of data records retrieved */
|
|
704
|
-
recordCount: number;
|
|
705
|
-
/** Whether this is a partial data set */
|
|
706
|
-
isPartial: boolean;
|
|
707
|
-
};
|
|
708
|
-
"extraction:completed": {
|
|
709
|
-
/** Unique ID of the extraction process */
|
|
710
|
-
workflowId: string;
|
|
711
|
-
/** Whether the extraction completed successfully */
|
|
712
|
-
success: boolean;
|
|
713
|
-
/** Final execution status */
|
|
714
|
-
finalRunState?: string;
|
|
715
|
-
/** Final processing state */
|
|
716
|
-
finalState?: string;
|
|
717
|
-
/** Number of records extracted (if successful) */
|
|
718
|
-
recordCount?: number;
|
|
719
|
-
/** Error message (if failed) */
|
|
720
|
-
error?: string;
|
|
721
|
-
};
|
|
722
|
-
};
|
|
723
|
-
type EventPayloadMap = EntityEventPayloads & ExtractionEventPayloads;
|
|
724
|
-
|
|
725
|
-
/**
|
|
726
|
-
* Unified event structure with discriminated union
|
|
727
|
-
*/
|
|
728
|
-
interface KadoaEvent<T extends keyof EventPayloadMap = keyof EventPayloadMap> {
|
|
729
|
-
/** Event type identifier */
|
|
730
|
-
type: T;
|
|
731
|
-
/** ISO timestamp when the event occurred */
|
|
732
|
-
timestamp: Date;
|
|
733
|
-
/** Module or component that emitted the event */
|
|
734
|
-
source: string;
|
|
735
|
-
/** Event-specific payload */
|
|
736
|
-
payload: EventPayloadMap[T];
|
|
737
|
-
/** Optional metadata for debugging and tracking */
|
|
738
|
-
metadata?: Record<string, unknown>;
|
|
739
|
-
}
|
|
740
|
-
/**
|
|
741
|
-
* Type aliases for convenience
|
|
742
|
-
*/
|
|
743
|
-
type KadoaEventName = keyof EventPayloadMap;
|
|
744
|
-
type KadoaEventPayload<T extends KadoaEventName> = EventPayloadMap[T];
|
|
745
|
-
type AnyKadoaEvent = KadoaEvent<KadoaEventName>;
|
|
746
|
-
/**
|
|
747
|
-
* Simplified type-safe event emitter for Kadoa SDK events
|
|
748
|
-
*/
|
|
749
|
-
declare class KadoaEventEmitter extends EventEmitter {
|
|
750
|
-
/**
|
|
751
|
-
* Emit a typed SDK event
|
|
752
|
-
*/
|
|
753
|
-
emit<T extends KadoaEventName>(eventName: T, payload: EventPayloadMap[T], source?: string, metadata?: Record<string, unknown>): boolean;
|
|
754
|
-
/**
|
|
755
|
-
* Subscribe to SDK events
|
|
756
|
-
*/
|
|
757
|
-
onEvent(listener: (event: AnyKadoaEvent) => void): this;
|
|
758
|
-
/**
|
|
759
|
-
* Subscribe to SDK events (once)
|
|
760
|
-
*/
|
|
761
|
-
onceEvent(listener: (event: AnyKadoaEvent) => void): this;
|
|
762
|
-
/**
|
|
763
|
-
* Unsubscribe from SDK events
|
|
764
|
-
*/
|
|
765
|
-
offEvent(listener: (event: AnyKadoaEvent) => void): this;
|
|
766
|
-
/**
|
|
767
|
-
* Remove all event listeners
|
|
768
|
-
*/
|
|
769
|
-
removeAllEventListeners(): this;
|
|
770
|
-
}
|
|
771
|
-
|
|
772
815
|
interface KadoaSDK {
|
|
773
816
|
configuration: Configuration;
|
|
774
817
|
axiosInstance: AxiosInstance;
|
|
@@ -811,69 +854,33 @@ declare function initializeSdk(config: KadoaConfig): KadoaSDK;
|
|
|
811
854
|
*/
|
|
812
855
|
declare function dispose(sdkInstance: KadoaSDK): void;
|
|
813
856
|
|
|
814
|
-
type
|
|
857
|
+
type NavigationMode = (typeof WorkflowWithExistingSchemaNavigationModeEnum)[keyof typeof WorkflowWithExistingSchemaNavigationModeEnum];
|
|
858
|
+
interface ExtractionConfig {
|
|
815
859
|
urls: string[];
|
|
816
|
-
navigationMode
|
|
817
|
-
name
|
|
818
|
-
location
|
|
860
|
+
navigationMode: NavigationMode;
|
|
861
|
+
name: string;
|
|
862
|
+
location: {
|
|
819
863
|
type: string;
|
|
820
864
|
};
|
|
821
|
-
pollingInterval
|
|
822
|
-
maxWaitTime
|
|
823
|
-
}
|
|
824
|
-
type
|
|
865
|
+
pollingInterval: number;
|
|
866
|
+
maxWaitTime: number;
|
|
867
|
+
}
|
|
868
|
+
type ExtractionOptions = {
|
|
869
|
+
urls: string[];
|
|
870
|
+
} & Partial<Omit<ExtractionConfig, "urls">>;
|
|
871
|
+
interface ExtractionResult {
|
|
825
872
|
workflowId: string | undefined;
|
|
826
873
|
workflow?: V4WorkflowsWorkflowIdGet200Response;
|
|
827
874
|
data?: Array<object>;
|
|
828
|
-
}
|
|
875
|
+
}
|
|
829
876
|
|
|
830
877
|
/**
|
|
831
878
|
* Run extraction workflow using dynamic entity detection
|
|
879
|
+
*
|
|
880
|
+
* @param sdkInstance The Kadoa SDK instance
|
|
881
|
+
* @param options Extraction configuration options
|
|
882
|
+
* @returns ExtractionResult containing workflow ID, workflow details, and extracted data
|
|
832
883
|
*/
|
|
833
884
|
declare function runExtraction(sdkInstance: KadoaSDK, options: ExtractionOptions): Promise<ExtractionResult>;
|
|
834
885
|
|
|
835
|
-
type
|
|
836
|
-
type KadoaSdkExceptionOptions = {
|
|
837
|
-
code?: KadoaErrorCode;
|
|
838
|
-
details?: Record<string, unknown>;
|
|
839
|
-
cause?: unknown;
|
|
840
|
-
};
|
|
841
|
-
declare class KadoaSdkException extends Error {
|
|
842
|
-
readonly code: KadoaErrorCode;
|
|
843
|
-
readonly details?: Record<string, unknown>;
|
|
844
|
-
readonly cause?: unknown;
|
|
845
|
-
constructor(message: string, options?: KadoaSdkExceptionOptions);
|
|
846
|
-
static from(error: unknown, details?: Record<string, unknown>): KadoaSdkException;
|
|
847
|
-
toJSON(): Record<string, unknown>;
|
|
848
|
-
toString(): string;
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
type KadoaHttpExceptionOptions = {
|
|
852
|
-
httpStatus?: number;
|
|
853
|
-
requestId?: string;
|
|
854
|
-
endpoint?: string;
|
|
855
|
-
method?: string;
|
|
856
|
-
responseBody?: unknown;
|
|
857
|
-
details?: Record<string, unknown>;
|
|
858
|
-
code?: KadoaErrorCode;
|
|
859
|
-
cause?: unknown;
|
|
860
|
-
};
|
|
861
|
-
declare class KadoaHttpException extends KadoaSdkException {
|
|
862
|
-
readonly httpStatus?: number;
|
|
863
|
-
readonly requestId?: string;
|
|
864
|
-
readonly endpoint?: string;
|
|
865
|
-
readonly method?: string;
|
|
866
|
-
readonly responseBody?: unknown;
|
|
867
|
-
constructor(message: string, options?: KadoaHttpExceptionOptions);
|
|
868
|
-
static fromAxiosError(error: AxiosError, extra?: {
|
|
869
|
-
message?: string;
|
|
870
|
-
details?: Record<string, unknown>;
|
|
871
|
-
}): KadoaHttpException;
|
|
872
|
-
toJSON(): Record<string, unknown>;
|
|
873
|
-
private static mapStatusToCode;
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
declare function isKadoaSdkException(error: unknown): error is KadoaSdkException;
|
|
877
|
-
declare function isKadoaHttpException(error: unknown): error is KadoaHttpException;
|
|
878
|
-
|
|
879
|
-
export { type AnyKadoaEvent, type ExtractionOptions, type ExtractionResult, type KadoaConfig, type KadoaErrorCode, type KadoaEvent, KadoaEventEmitter, type KadoaEventName, type KadoaEventPayload, KadoaHttpException, type KadoaHttpExceptionOptions, type KadoaSDK, KadoaSdkException, type KadoaSdkExceptionOptions, dispose, initializeSdk, isKadoaHttpException, isKadoaSdkException, runExtraction };
|
|
886
|
+
export { type ExtractionOptions, type ExtractionResult, type KadoaConfig, type KadoaErrorCode, type KadoaEvent, KadoaEventEmitter, KadoaHttpException, type KadoaSDK, KadoaSdkException, dispose, initializeSdk, isKadoaHttpException, isKadoaSdkException, runExtraction };
|