@kadoa/node-sdk 0.2.0 → 0.4.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 +19 -21
- package/dist/index.d.mts +171 -52
- package/dist/index.d.ts +171 -52
- package/dist/index.js +585 -418
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +610 -440
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,27 +5,26 @@ 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/node-sdk
|
|
8
|
+
npm install @kadoa/node-sdk
|
|
9
9
|
# or
|
|
10
|
-
yarn add @kadoa/node-sdk
|
|
10
|
+
yarn add @kadoa/node-sdk
|
|
11
11
|
# or
|
|
12
|
-
pnpm add @kadoa/node-sdk
|
|
12
|
+
pnpm add @kadoa/node-sdk
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
**Note:** `axios` is required as a peer dependency.
|
|
16
15
|
|
|
17
16
|
## Quick Start
|
|
18
17
|
|
|
19
18
|
```typescript
|
|
20
|
-
import {
|
|
19
|
+
import { KadoaClient } from '@kadoa/node-sdk';
|
|
21
20
|
|
|
22
|
-
// Initialize the
|
|
23
|
-
const
|
|
21
|
+
// Initialize the client
|
|
22
|
+
const client = new KadoaClient({
|
|
24
23
|
apiKey: 'your-api-key'
|
|
25
24
|
});
|
|
26
25
|
|
|
27
26
|
// Run an extraction
|
|
28
|
-
const result = await
|
|
27
|
+
const result = await client.extraction.run({
|
|
29
28
|
urls: ['https://example.com'],
|
|
30
29
|
name: 'My Extraction Workflow'
|
|
31
30
|
});
|
|
@@ -40,7 +39,7 @@ if (result) {
|
|
|
40
39
|
### Basic Configuration
|
|
41
40
|
|
|
42
41
|
```typescript
|
|
43
|
-
const
|
|
42
|
+
const client = new KadoaClient({
|
|
44
43
|
apiKey: 'your-api-key',
|
|
45
44
|
baseUrl: 'https://api.kadoa.com', // optional
|
|
46
45
|
timeout: 30000 // optional, in ms
|
|
@@ -56,12 +55,12 @@ KADOA_TIMEOUT=30000
|
|
|
56
55
|
```
|
|
57
56
|
|
|
58
57
|
```typescript
|
|
59
|
-
import {
|
|
58
|
+
import { KadoaClient } from '@kadoa/node-sdk';
|
|
60
59
|
import { config } from 'dotenv';
|
|
61
60
|
|
|
62
61
|
config();
|
|
63
62
|
|
|
64
|
-
const
|
|
63
|
+
const client = new KadoaClient({
|
|
65
64
|
apiKey: process.env.KADOA_API_KEY!,
|
|
66
65
|
baseUrl: process.env.KADOA_API_URL,
|
|
67
66
|
timeout: parseInt(process.env.KADOA_TIMEOUT || '30000')
|
|
@@ -71,10 +70,10 @@ const sdk = initializeSdk({
|
|
|
71
70
|
## Event Handling
|
|
72
71
|
|
|
73
72
|
```typescript
|
|
74
|
-
const
|
|
73
|
+
const client = new KadoaClient({ apiKey: 'your-api-key' });
|
|
75
74
|
|
|
76
75
|
// Listen to events
|
|
77
|
-
|
|
76
|
+
client.onEvent((event) => {
|
|
78
77
|
console.log('Event:', event);
|
|
79
78
|
});
|
|
80
79
|
|
|
@@ -88,18 +87,18 @@ sdk.onEvent((event) => {
|
|
|
88
87
|
|
|
89
88
|
## API Reference
|
|
90
89
|
|
|
91
|
-
###
|
|
90
|
+
### new KadoaClient(config)
|
|
92
91
|
- `apiKey` (required): Your Kadoa API key
|
|
93
|
-
- `baseUrl` (optional): API base URL
|
|
94
|
-
- `timeout` (optional): Request timeout in milliseconds
|
|
92
|
+
- `baseUrl` (optional): API base URL (default: 'https://api.kadoa.com')
|
|
93
|
+
- `timeout` (optional): Request timeout in milliseconds (default: 30000)
|
|
95
94
|
|
|
96
|
-
Returns
|
|
97
|
-
- `
|
|
98
|
-
- `axiosInstance`: Configured HTTP client
|
|
95
|
+
Returns a client instance with:
|
|
96
|
+
- `extraction`: Extraction module with `run()` method
|
|
99
97
|
- `onEvent()`: Subscribe to events
|
|
100
98
|
- `offEvent()`: Unsubscribe from events
|
|
99
|
+
- `dispose()`: Releases resources and removes all event listeners
|
|
101
100
|
|
|
102
|
-
###
|
|
101
|
+
### client.extraction.run(options)
|
|
103
102
|
- `urls`: Array of URLs to extract from
|
|
104
103
|
- `name`: Workflow name
|
|
105
104
|
- Additional options available in API documentation
|
|
@@ -111,7 +110,6 @@ See [examples directory](https://github.com/kadoa-org/kadoa-sdks/tree/main/examp
|
|
|
111
110
|
## Requirements
|
|
112
111
|
|
|
113
112
|
- Node.js 22+
|
|
114
|
-
- TypeScript 5+ (for TypeScript projects)
|
|
115
113
|
|
|
116
114
|
## License
|
|
117
115
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { AxiosError, AxiosInstance } from 'axios';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Event payload definitions for entity detection
|
|
6
|
+
*/
|
|
4
7
|
type EntityEventPayloads = {
|
|
5
8
|
"entity:detected": {
|
|
6
9
|
/** Name of the detected entity type (e.g., "Product", "Article", "Job Listing") */
|
|
@@ -17,6 +20,9 @@ type EntityEventPayloads = {
|
|
|
17
20
|
url: string;
|
|
18
21
|
};
|
|
19
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Event payload definitions for extraction workflow
|
|
25
|
+
*/
|
|
20
26
|
type ExtractionEventPayloads = {
|
|
21
27
|
"extraction:started": {
|
|
22
28
|
/** Unique ID of the extraction process */
|
|
@@ -61,6 +67,9 @@ type ExtractionEventPayloads = {
|
|
|
61
67
|
error?: string;
|
|
62
68
|
};
|
|
63
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Combined event payload map for all SDK events
|
|
72
|
+
*/
|
|
64
73
|
type EventPayloadMap = EntityEventPayloads & ExtractionEventPayloads;
|
|
65
74
|
|
|
66
75
|
/**
|
|
@@ -119,11 +128,57 @@ declare class KadoaSdkException extends Error {
|
|
|
119
128
|
readonly code: KadoaErrorCode;
|
|
120
129
|
readonly details?: Record<string, unknown>;
|
|
121
130
|
readonly cause?: unknown;
|
|
131
|
+
static readonly ERROR_MESSAGES: {
|
|
132
|
+
readonly CONFIG_ERROR: "Invalid configuration provided";
|
|
133
|
+
readonly AUTH_FAILED: "Authentication failed. Please check your API key";
|
|
134
|
+
readonly RATE_LIMITED: "Rate limit exceeded. Please try again later";
|
|
135
|
+
readonly NETWORK_ERROR: "Network error occurred";
|
|
136
|
+
readonly SERVER_ERROR: "Server error occurred";
|
|
137
|
+
readonly PARSE_ERROR: "Failed to parse response";
|
|
138
|
+
readonly NO_WORKFLOW_ID: "Failed to start extraction process - no ID received";
|
|
139
|
+
readonly WORKFLOW_CREATE_FAILED: "Failed to create workflow";
|
|
140
|
+
readonly WORKFLOW_TIMEOUT: "Workflow processing timed out";
|
|
141
|
+
readonly WORKFLOW_UNEXPECTED_STATUS: "Extraction completed with unexpected status";
|
|
142
|
+
readonly PROGRESS_CHECK_FAILED: "Failed to check extraction progress";
|
|
143
|
+
readonly DATA_FETCH_FAILED: "Failed to retrieve extracted data from workflow";
|
|
144
|
+
readonly NO_URLS: "At least one URL is required for extraction";
|
|
145
|
+
readonly NO_API_KEY: "API key is required for entity detection";
|
|
146
|
+
readonly LINK_REQUIRED: "Link is required for entity field detection";
|
|
147
|
+
readonly NO_PREDICTIONS: "No entity predictions returned from the API";
|
|
148
|
+
readonly EXTRACTION_FAILED: "Data extraction failed for the provided URLs";
|
|
149
|
+
readonly ENTITY_FETCH_FAILED: "Failed to fetch entity fields";
|
|
150
|
+
};
|
|
122
151
|
constructor(message: string, options?: KadoaSdkExceptionOptions);
|
|
123
152
|
static from(error: unknown, details?: Record<string, unknown>): KadoaSdkException;
|
|
124
153
|
toJSON(): Record<string, unknown>;
|
|
125
154
|
toString(): string;
|
|
155
|
+
toDetailedString(): string;
|
|
156
|
+
static isInstance(error: unknown): error is KadoaSdkException;
|
|
157
|
+
static wrap(error: unknown, extra?: {
|
|
158
|
+
message?: string;
|
|
159
|
+
details?: Record<string, unknown>;
|
|
160
|
+
}): KadoaSdkException;
|
|
126
161
|
}
|
|
162
|
+
declare const ERROR_MESSAGES: {
|
|
163
|
+
readonly CONFIG_ERROR: "Invalid configuration provided";
|
|
164
|
+
readonly AUTH_FAILED: "Authentication failed. Please check your API key";
|
|
165
|
+
readonly RATE_LIMITED: "Rate limit exceeded. Please try again later";
|
|
166
|
+
readonly NETWORK_ERROR: "Network error occurred";
|
|
167
|
+
readonly SERVER_ERROR: "Server error occurred";
|
|
168
|
+
readonly PARSE_ERROR: "Failed to parse response";
|
|
169
|
+
readonly NO_WORKFLOW_ID: "Failed to start extraction process - no ID received";
|
|
170
|
+
readonly WORKFLOW_CREATE_FAILED: "Failed to create workflow";
|
|
171
|
+
readonly WORKFLOW_TIMEOUT: "Workflow processing timed out";
|
|
172
|
+
readonly WORKFLOW_UNEXPECTED_STATUS: "Extraction completed with unexpected status";
|
|
173
|
+
readonly PROGRESS_CHECK_FAILED: "Failed to check extraction progress";
|
|
174
|
+
readonly DATA_FETCH_FAILED: "Failed to retrieve extracted data from workflow";
|
|
175
|
+
readonly NO_URLS: "At least one URL is required for extraction";
|
|
176
|
+
readonly NO_API_KEY: "API key is required for entity detection";
|
|
177
|
+
readonly LINK_REQUIRED: "Link is required for entity field detection";
|
|
178
|
+
readonly NO_PREDICTIONS: "No entity predictions returned from the API";
|
|
179
|
+
readonly EXTRACTION_FAILED: "Data extraction failed for the provided URLs";
|
|
180
|
+
readonly ENTITY_FETCH_FAILED: "Failed to fetch entity fields";
|
|
181
|
+
};
|
|
127
182
|
|
|
128
183
|
type KadoaHttpExceptionOptions = {
|
|
129
184
|
httpStatus?: number;
|
|
@@ -147,12 +202,14 @@ declare class KadoaHttpException extends KadoaSdkException {
|
|
|
147
202
|
details?: Record<string, unknown>;
|
|
148
203
|
}): KadoaHttpException;
|
|
149
204
|
toJSON(): Record<string, unknown>;
|
|
150
|
-
|
|
205
|
+
toDetailedString(): string;
|
|
206
|
+
static wrap(error: unknown, extra?: {
|
|
207
|
+
message?: string;
|
|
208
|
+
details?: Record<string, unknown>;
|
|
209
|
+
}): KadoaSdkException | KadoaHttpException;
|
|
210
|
+
static mapStatusToCode(errorOrStatus: AxiosError | number): KadoaErrorCode;
|
|
151
211
|
}
|
|
152
212
|
|
|
153
|
-
declare function isKadoaSdkException(error: unknown): error is KadoaSdkException;
|
|
154
|
-
declare function isKadoaHttpException(error: unknown): error is KadoaHttpException;
|
|
155
|
-
|
|
156
213
|
/**
|
|
157
214
|
* Kadoa API
|
|
158
215
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
@@ -812,48 +869,6 @@ declare const V4WorkflowsWorkflowIdGet200ResponseSchemaTypeEnum: {
|
|
|
812
869
|
};
|
|
813
870
|
type V4WorkflowsWorkflowIdGet200ResponseSchemaTypeEnum = typeof V4WorkflowsWorkflowIdGet200ResponseSchemaTypeEnum[keyof typeof V4WorkflowsWorkflowIdGet200ResponseSchemaTypeEnum];
|
|
814
871
|
|
|
815
|
-
interface KadoaSDK {
|
|
816
|
-
configuration: Configuration;
|
|
817
|
-
axiosInstance: AxiosInstance;
|
|
818
|
-
baseUrl: string;
|
|
819
|
-
events: KadoaEventEmitter;
|
|
820
|
-
emit: <T extends KadoaEventName>(eventName: T, payload: EventPayloadMap[T], source?: string, metadata?: Record<string, unknown>) => void;
|
|
821
|
-
onEvent: (listener: (event: AnyKadoaEvent) => void) => void;
|
|
822
|
-
offEvent: (listener: (event: AnyKadoaEvent) => void) => void;
|
|
823
|
-
}
|
|
824
|
-
interface KadoaConfig {
|
|
825
|
-
apiKey: string;
|
|
826
|
-
baseUrl?: string;
|
|
827
|
-
timeout?: number;
|
|
828
|
-
}
|
|
829
|
-
/**
|
|
830
|
-
* Initialize a Kadoa SDK instance
|
|
831
|
-
* @param config Configuration options for the Kadoa SDK
|
|
832
|
-
* @returns Initialized KadoaSDK instance
|
|
833
|
-
*
|
|
834
|
-
* @example
|
|
835
|
-
* ```typescript
|
|
836
|
-
* import { initializeApp } from '@kadoa/sdk';
|
|
837
|
-
*
|
|
838
|
-
* const sdkInstance = initializeApp({
|
|
839
|
-
* apiKey: 'your-api-key'
|
|
840
|
-
* });
|
|
841
|
-
* ```
|
|
842
|
-
*/
|
|
843
|
-
declare function initializeSdk(config: KadoaConfig): KadoaSDK;
|
|
844
|
-
/**
|
|
845
|
-
* Dispose of a KadoaApp instance and clean up resources
|
|
846
|
-
* @param sdkInstance The KadoaApp instance to dispose
|
|
847
|
-
*
|
|
848
|
-
* @example
|
|
849
|
-
* ```typescript
|
|
850
|
-
* const sdkInstance = initializeSdk({ apiKey, enableEvents: true });
|
|
851
|
-
* // ... use the app
|
|
852
|
-
* dispose(sdkInstance); // Clean up when done
|
|
853
|
-
* ```
|
|
854
|
-
*/
|
|
855
|
-
declare function dispose(sdkInstance: KadoaSDK): void;
|
|
856
|
-
|
|
857
872
|
type NavigationMode = (typeof WorkflowWithExistingSchemaNavigationModeEnum)[keyof typeof WorkflowWithExistingSchemaNavigationModeEnum];
|
|
858
873
|
interface ExtractionConfig {
|
|
859
874
|
urls: string[];
|
|
@@ -864,6 +879,7 @@ interface ExtractionConfig {
|
|
|
864
879
|
};
|
|
865
880
|
pollingInterval: number;
|
|
866
881
|
maxWaitTime: number;
|
|
882
|
+
maxRecords: number;
|
|
867
883
|
}
|
|
868
884
|
type ExtractionOptions = {
|
|
869
885
|
urls: string[];
|
|
@@ -875,12 +891,115 @@ interface ExtractionResult {
|
|
|
875
891
|
}
|
|
876
892
|
|
|
877
893
|
/**
|
|
878
|
-
*
|
|
894
|
+
* ExtractionModule provides extraction-related functionality
|
|
895
|
+
*/
|
|
896
|
+
declare class ExtractionModule {
|
|
897
|
+
private readonly runExtractionCommand;
|
|
898
|
+
constructor(client: KadoaClient);
|
|
899
|
+
/**
|
|
900
|
+
* Run extraction workflow using dynamic entity detection
|
|
901
|
+
*
|
|
902
|
+
* @param options Extraction configuration options
|
|
903
|
+
* @returns ExtractionResult containing workflow ID, workflow details, and extracted data
|
|
904
|
+
*
|
|
905
|
+
* @example
|
|
906
|
+
* ```typescript
|
|
907
|
+
* const result = await client.extraction.run({
|
|
908
|
+
* urls: ['https://example.com'],
|
|
909
|
+
* name: 'My Extraction'
|
|
910
|
+
* });
|
|
911
|
+
* ```
|
|
912
|
+
*/
|
|
913
|
+
run(options: ExtractionOptions): Promise<ExtractionResult>;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
interface KadoaClientConfig {
|
|
917
|
+
apiKey: string;
|
|
918
|
+
baseUrl?: string;
|
|
919
|
+
timeout?: number;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* KadoaClient provides an object-oriented interface to the Kadoa SDK
|
|
923
|
+
*
|
|
924
|
+
* @example
|
|
925
|
+
* ```typescript
|
|
926
|
+
* import { KadoaClient } from '@kadoa/sdk';
|
|
927
|
+
*
|
|
928
|
+
* const client = new KadoaClient({
|
|
929
|
+
* apiKey: 'your-api-key'
|
|
930
|
+
* });
|
|
879
931
|
*
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
*
|
|
932
|
+
* const result = await client.extraction.run({
|
|
933
|
+
* urls: ['https://example.com'],
|
|
934
|
+
* name: 'My Extraction'
|
|
935
|
+
* });
|
|
936
|
+
* ```
|
|
883
937
|
*/
|
|
884
|
-
declare
|
|
938
|
+
declare class KadoaClient {
|
|
939
|
+
private readonly _configuration;
|
|
940
|
+
private readonly _axiosInstance;
|
|
941
|
+
private readonly _baseUrl;
|
|
942
|
+
private readonly _timeout;
|
|
943
|
+
private readonly _events;
|
|
944
|
+
readonly extraction: ExtractionModule;
|
|
945
|
+
constructor(config: KadoaClientConfig);
|
|
946
|
+
/**
|
|
947
|
+
* Register an event listener
|
|
948
|
+
*
|
|
949
|
+
* @param listener Function to handle events
|
|
950
|
+
*/
|
|
951
|
+
onEvent(listener: (event: AnyKadoaEvent) => void): void;
|
|
952
|
+
/**
|
|
953
|
+
* Remove an event listener
|
|
954
|
+
*
|
|
955
|
+
* @param listener Function to remove from event handlers
|
|
956
|
+
*/
|
|
957
|
+
offEvent(listener: (event: AnyKadoaEvent) => void): void;
|
|
958
|
+
/**
|
|
959
|
+
* Emit an event
|
|
960
|
+
* @internal
|
|
961
|
+
*
|
|
962
|
+
* @param eventName The name of the event
|
|
963
|
+
* @param payload The event payload
|
|
964
|
+
* @param source Optional source identifier
|
|
965
|
+
* @param metadata Optional metadata
|
|
966
|
+
*/
|
|
967
|
+
emit<T extends KadoaEventName>(eventName: T, payload: EventPayloadMap[T], source?: string, metadata?: Record<string, unknown>): void;
|
|
968
|
+
/**
|
|
969
|
+
* Get the underlying configuration
|
|
970
|
+
*
|
|
971
|
+
* @returns The configuration object
|
|
972
|
+
*/
|
|
973
|
+
get configuration(): Configuration;
|
|
974
|
+
/**
|
|
975
|
+
* Get the axios instance
|
|
976
|
+
*
|
|
977
|
+
* @returns The axios instance
|
|
978
|
+
*/
|
|
979
|
+
get axiosInstance(): AxiosInstance;
|
|
980
|
+
/**
|
|
981
|
+
* Get the base URL
|
|
982
|
+
*
|
|
983
|
+
* @returns The base URL
|
|
984
|
+
*/
|
|
985
|
+
get baseUrl(): string;
|
|
986
|
+
/**
|
|
987
|
+
* Get the timeout value
|
|
988
|
+
*
|
|
989
|
+
* @returns The timeout in milliseconds
|
|
990
|
+
*/
|
|
991
|
+
get timeout(): number;
|
|
992
|
+
/**
|
|
993
|
+
* Get the event emitter
|
|
994
|
+
* @internal
|
|
995
|
+
*
|
|
996
|
+
* @returns The event emitter
|
|
997
|
+
*/
|
|
998
|
+
get events(): KadoaEventEmitter;
|
|
999
|
+
/**
|
|
1000
|
+
* Dispose of the client and clean up resources
|
|
1001
|
+
*/
|
|
1002
|
+
dispose(): void;
|
|
1003
|
+
}
|
|
885
1004
|
|
|
886
|
-
export { type ExtractionOptions, type ExtractionResult, type
|
|
1005
|
+
export { ERROR_MESSAGES, type ExtractionOptions, type ExtractionResult, KadoaClient, type KadoaClientConfig, type KadoaErrorCode, type KadoaEvent, KadoaEventEmitter, KadoaHttpException, KadoaSdkException };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { AxiosError, AxiosInstance } from 'axios';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Event payload definitions for entity detection
|
|
6
|
+
*/
|
|
4
7
|
type EntityEventPayloads = {
|
|
5
8
|
"entity:detected": {
|
|
6
9
|
/** Name of the detected entity type (e.g., "Product", "Article", "Job Listing") */
|
|
@@ -17,6 +20,9 @@ type EntityEventPayloads = {
|
|
|
17
20
|
url: string;
|
|
18
21
|
};
|
|
19
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Event payload definitions for extraction workflow
|
|
25
|
+
*/
|
|
20
26
|
type ExtractionEventPayloads = {
|
|
21
27
|
"extraction:started": {
|
|
22
28
|
/** Unique ID of the extraction process */
|
|
@@ -61,6 +67,9 @@ type ExtractionEventPayloads = {
|
|
|
61
67
|
error?: string;
|
|
62
68
|
};
|
|
63
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Combined event payload map for all SDK events
|
|
72
|
+
*/
|
|
64
73
|
type EventPayloadMap = EntityEventPayloads & ExtractionEventPayloads;
|
|
65
74
|
|
|
66
75
|
/**
|
|
@@ -119,11 +128,57 @@ declare class KadoaSdkException extends Error {
|
|
|
119
128
|
readonly code: KadoaErrorCode;
|
|
120
129
|
readonly details?: Record<string, unknown>;
|
|
121
130
|
readonly cause?: unknown;
|
|
131
|
+
static readonly ERROR_MESSAGES: {
|
|
132
|
+
readonly CONFIG_ERROR: "Invalid configuration provided";
|
|
133
|
+
readonly AUTH_FAILED: "Authentication failed. Please check your API key";
|
|
134
|
+
readonly RATE_LIMITED: "Rate limit exceeded. Please try again later";
|
|
135
|
+
readonly NETWORK_ERROR: "Network error occurred";
|
|
136
|
+
readonly SERVER_ERROR: "Server error occurred";
|
|
137
|
+
readonly PARSE_ERROR: "Failed to parse response";
|
|
138
|
+
readonly NO_WORKFLOW_ID: "Failed to start extraction process - no ID received";
|
|
139
|
+
readonly WORKFLOW_CREATE_FAILED: "Failed to create workflow";
|
|
140
|
+
readonly WORKFLOW_TIMEOUT: "Workflow processing timed out";
|
|
141
|
+
readonly WORKFLOW_UNEXPECTED_STATUS: "Extraction completed with unexpected status";
|
|
142
|
+
readonly PROGRESS_CHECK_FAILED: "Failed to check extraction progress";
|
|
143
|
+
readonly DATA_FETCH_FAILED: "Failed to retrieve extracted data from workflow";
|
|
144
|
+
readonly NO_URLS: "At least one URL is required for extraction";
|
|
145
|
+
readonly NO_API_KEY: "API key is required for entity detection";
|
|
146
|
+
readonly LINK_REQUIRED: "Link is required for entity field detection";
|
|
147
|
+
readonly NO_PREDICTIONS: "No entity predictions returned from the API";
|
|
148
|
+
readonly EXTRACTION_FAILED: "Data extraction failed for the provided URLs";
|
|
149
|
+
readonly ENTITY_FETCH_FAILED: "Failed to fetch entity fields";
|
|
150
|
+
};
|
|
122
151
|
constructor(message: string, options?: KadoaSdkExceptionOptions);
|
|
123
152
|
static from(error: unknown, details?: Record<string, unknown>): KadoaSdkException;
|
|
124
153
|
toJSON(): Record<string, unknown>;
|
|
125
154
|
toString(): string;
|
|
155
|
+
toDetailedString(): string;
|
|
156
|
+
static isInstance(error: unknown): error is KadoaSdkException;
|
|
157
|
+
static wrap(error: unknown, extra?: {
|
|
158
|
+
message?: string;
|
|
159
|
+
details?: Record<string, unknown>;
|
|
160
|
+
}): KadoaSdkException;
|
|
126
161
|
}
|
|
162
|
+
declare const ERROR_MESSAGES: {
|
|
163
|
+
readonly CONFIG_ERROR: "Invalid configuration provided";
|
|
164
|
+
readonly AUTH_FAILED: "Authentication failed. Please check your API key";
|
|
165
|
+
readonly RATE_LIMITED: "Rate limit exceeded. Please try again later";
|
|
166
|
+
readonly NETWORK_ERROR: "Network error occurred";
|
|
167
|
+
readonly SERVER_ERROR: "Server error occurred";
|
|
168
|
+
readonly PARSE_ERROR: "Failed to parse response";
|
|
169
|
+
readonly NO_WORKFLOW_ID: "Failed to start extraction process - no ID received";
|
|
170
|
+
readonly WORKFLOW_CREATE_FAILED: "Failed to create workflow";
|
|
171
|
+
readonly WORKFLOW_TIMEOUT: "Workflow processing timed out";
|
|
172
|
+
readonly WORKFLOW_UNEXPECTED_STATUS: "Extraction completed with unexpected status";
|
|
173
|
+
readonly PROGRESS_CHECK_FAILED: "Failed to check extraction progress";
|
|
174
|
+
readonly DATA_FETCH_FAILED: "Failed to retrieve extracted data from workflow";
|
|
175
|
+
readonly NO_URLS: "At least one URL is required for extraction";
|
|
176
|
+
readonly NO_API_KEY: "API key is required for entity detection";
|
|
177
|
+
readonly LINK_REQUIRED: "Link is required for entity field detection";
|
|
178
|
+
readonly NO_PREDICTIONS: "No entity predictions returned from the API";
|
|
179
|
+
readonly EXTRACTION_FAILED: "Data extraction failed for the provided URLs";
|
|
180
|
+
readonly ENTITY_FETCH_FAILED: "Failed to fetch entity fields";
|
|
181
|
+
};
|
|
127
182
|
|
|
128
183
|
type KadoaHttpExceptionOptions = {
|
|
129
184
|
httpStatus?: number;
|
|
@@ -147,12 +202,14 @@ declare class KadoaHttpException extends KadoaSdkException {
|
|
|
147
202
|
details?: Record<string, unknown>;
|
|
148
203
|
}): KadoaHttpException;
|
|
149
204
|
toJSON(): Record<string, unknown>;
|
|
150
|
-
|
|
205
|
+
toDetailedString(): string;
|
|
206
|
+
static wrap(error: unknown, extra?: {
|
|
207
|
+
message?: string;
|
|
208
|
+
details?: Record<string, unknown>;
|
|
209
|
+
}): KadoaSdkException | KadoaHttpException;
|
|
210
|
+
static mapStatusToCode(errorOrStatus: AxiosError | number): KadoaErrorCode;
|
|
151
211
|
}
|
|
152
212
|
|
|
153
|
-
declare function isKadoaSdkException(error: unknown): error is KadoaSdkException;
|
|
154
|
-
declare function isKadoaHttpException(error: unknown): error is KadoaHttpException;
|
|
155
|
-
|
|
156
213
|
/**
|
|
157
214
|
* Kadoa API
|
|
158
215
|
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
@@ -812,48 +869,6 @@ declare const V4WorkflowsWorkflowIdGet200ResponseSchemaTypeEnum: {
|
|
|
812
869
|
};
|
|
813
870
|
type V4WorkflowsWorkflowIdGet200ResponseSchemaTypeEnum = typeof V4WorkflowsWorkflowIdGet200ResponseSchemaTypeEnum[keyof typeof V4WorkflowsWorkflowIdGet200ResponseSchemaTypeEnum];
|
|
814
871
|
|
|
815
|
-
interface KadoaSDK {
|
|
816
|
-
configuration: Configuration;
|
|
817
|
-
axiosInstance: AxiosInstance;
|
|
818
|
-
baseUrl: string;
|
|
819
|
-
events: KadoaEventEmitter;
|
|
820
|
-
emit: <T extends KadoaEventName>(eventName: T, payload: EventPayloadMap[T], source?: string, metadata?: Record<string, unknown>) => void;
|
|
821
|
-
onEvent: (listener: (event: AnyKadoaEvent) => void) => void;
|
|
822
|
-
offEvent: (listener: (event: AnyKadoaEvent) => void) => void;
|
|
823
|
-
}
|
|
824
|
-
interface KadoaConfig {
|
|
825
|
-
apiKey: string;
|
|
826
|
-
baseUrl?: string;
|
|
827
|
-
timeout?: number;
|
|
828
|
-
}
|
|
829
|
-
/**
|
|
830
|
-
* Initialize a Kadoa SDK instance
|
|
831
|
-
* @param config Configuration options for the Kadoa SDK
|
|
832
|
-
* @returns Initialized KadoaSDK instance
|
|
833
|
-
*
|
|
834
|
-
* @example
|
|
835
|
-
* ```typescript
|
|
836
|
-
* import { initializeApp } from '@kadoa/sdk';
|
|
837
|
-
*
|
|
838
|
-
* const sdkInstance = initializeApp({
|
|
839
|
-
* apiKey: 'your-api-key'
|
|
840
|
-
* });
|
|
841
|
-
* ```
|
|
842
|
-
*/
|
|
843
|
-
declare function initializeSdk(config: KadoaConfig): KadoaSDK;
|
|
844
|
-
/**
|
|
845
|
-
* Dispose of a KadoaApp instance and clean up resources
|
|
846
|
-
* @param sdkInstance The KadoaApp instance to dispose
|
|
847
|
-
*
|
|
848
|
-
* @example
|
|
849
|
-
* ```typescript
|
|
850
|
-
* const sdkInstance = initializeSdk({ apiKey, enableEvents: true });
|
|
851
|
-
* // ... use the app
|
|
852
|
-
* dispose(sdkInstance); // Clean up when done
|
|
853
|
-
* ```
|
|
854
|
-
*/
|
|
855
|
-
declare function dispose(sdkInstance: KadoaSDK): void;
|
|
856
|
-
|
|
857
872
|
type NavigationMode = (typeof WorkflowWithExistingSchemaNavigationModeEnum)[keyof typeof WorkflowWithExistingSchemaNavigationModeEnum];
|
|
858
873
|
interface ExtractionConfig {
|
|
859
874
|
urls: string[];
|
|
@@ -864,6 +879,7 @@ interface ExtractionConfig {
|
|
|
864
879
|
};
|
|
865
880
|
pollingInterval: number;
|
|
866
881
|
maxWaitTime: number;
|
|
882
|
+
maxRecords: number;
|
|
867
883
|
}
|
|
868
884
|
type ExtractionOptions = {
|
|
869
885
|
urls: string[];
|
|
@@ -875,12 +891,115 @@ interface ExtractionResult {
|
|
|
875
891
|
}
|
|
876
892
|
|
|
877
893
|
/**
|
|
878
|
-
*
|
|
894
|
+
* ExtractionModule provides extraction-related functionality
|
|
895
|
+
*/
|
|
896
|
+
declare class ExtractionModule {
|
|
897
|
+
private readonly runExtractionCommand;
|
|
898
|
+
constructor(client: KadoaClient);
|
|
899
|
+
/**
|
|
900
|
+
* Run extraction workflow using dynamic entity detection
|
|
901
|
+
*
|
|
902
|
+
* @param options Extraction configuration options
|
|
903
|
+
* @returns ExtractionResult containing workflow ID, workflow details, and extracted data
|
|
904
|
+
*
|
|
905
|
+
* @example
|
|
906
|
+
* ```typescript
|
|
907
|
+
* const result = await client.extraction.run({
|
|
908
|
+
* urls: ['https://example.com'],
|
|
909
|
+
* name: 'My Extraction'
|
|
910
|
+
* });
|
|
911
|
+
* ```
|
|
912
|
+
*/
|
|
913
|
+
run(options: ExtractionOptions): Promise<ExtractionResult>;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
interface KadoaClientConfig {
|
|
917
|
+
apiKey: string;
|
|
918
|
+
baseUrl?: string;
|
|
919
|
+
timeout?: number;
|
|
920
|
+
}
|
|
921
|
+
/**
|
|
922
|
+
* KadoaClient provides an object-oriented interface to the Kadoa SDK
|
|
923
|
+
*
|
|
924
|
+
* @example
|
|
925
|
+
* ```typescript
|
|
926
|
+
* import { KadoaClient } from '@kadoa/sdk';
|
|
927
|
+
*
|
|
928
|
+
* const client = new KadoaClient({
|
|
929
|
+
* apiKey: 'your-api-key'
|
|
930
|
+
* });
|
|
879
931
|
*
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
*
|
|
932
|
+
* const result = await client.extraction.run({
|
|
933
|
+
* urls: ['https://example.com'],
|
|
934
|
+
* name: 'My Extraction'
|
|
935
|
+
* });
|
|
936
|
+
* ```
|
|
883
937
|
*/
|
|
884
|
-
declare
|
|
938
|
+
declare class KadoaClient {
|
|
939
|
+
private readonly _configuration;
|
|
940
|
+
private readonly _axiosInstance;
|
|
941
|
+
private readonly _baseUrl;
|
|
942
|
+
private readonly _timeout;
|
|
943
|
+
private readonly _events;
|
|
944
|
+
readonly extraction: ExtractionModule;
|
|
945
|
+
constructor(config: KadoaClientConfig);
|
|
946
|
+
/**
|
|
947
|
+
* Register an event listener
|
|
948
|
+
*
|
|
949
|
+
* @param listener Function to handle events
|
|
950
|
+
*/
|
|
951
|
+
onEvent(listener: (event: AnyKadoaEvent) => void): void;
|
|
952
|
+
/**
|
|
953
|
+
* Remove an event listener
|
|
954
|
+
*
|
|
955
|
+
* @param listener Function to remove from event handlers
|
|
956
|
+
*/
|
|
957
|
+
offEvent(listener: (event: AnyKadoaEvent) => void): void;
|
|
958
|
+
/**
|
|
959
|
+
* Emit an event
|
|
960
|
+
* @internal
|
|
961
|
+
*
|
|
962
|
+
* @param eventName The name of the event
|
|
963
|
+
* @param payload The event payload
|
|
964
|
+
* @param source Optional source identifier
|
|
965
|
+
* @param metadata Optional metadata
|
|
966
|
+
*/
|
|
967
|
+
emit<T extends KadoaEventName>(eventName: T, payload: EventPayloadMap[T], source?: string, metadata?: Record<string, unknown>): void;
|
|
968
|
+
/**
|
|
969
|
+
* Get the underlying configuration
|
|
970
|
+
*
|
|
971
|
+
* @returns The configuration object
|
|
972
|
+
*/
|
|
973
|
+
get configuration(): Configuration;
|
|
974
|
+
/**
|
|
975
|
+
* Get the axios instance
|
|
976
|
+
*
|
|
977
|
+
* @returns The axios instance
|
|
978
|
+
*/
|
|
979
|
+
get axiosInstance(): AxiosInstance;
|
|
980
|
+
/**
|
|
981
|
+
* Get the base URL
|
|
982
|
+
*
|
|
983
|
+
* @returns The base URL
|
|
984
|
+
*/
|
|
985
|
+
get baseUrl(): string;
|
|
986
|
+
/**
|
|
987
|
+
* Get the timeout value
|
|
988
|
+
*
|
|
989
|
+
* @returns The timeout in milliseconds
|
|
990
|
+
*/
|
|
991
|
+
get timeout(): number;
|
|
992
|
+
/**
|
|
993
|
+
* Get the event emitter
|
|
994
|
+
* @internal
|
|
995
|
+
*
|
|
996
|
+
* @returns The event emitter
|
|
997
|
+
*/
|
|
998
|
+
get events(): KadoaEventEmitter;
|
|
999
|
+
/**
|
|
1000
|
+
* Dispose of the client and clean up resources
|
|
1001
|
+
*/
|
|
1002
|
+
dispose(): void;
|
|
1003
|
+
}
|
|
885
1004
|
|
|
886
|
-
export { type ExtractionOptions, type ExtractionResult, type
|
|
1005
|
+
export { ERROR_MESSAGES, type ExtractionOptions, type ExtractionResult, KadoaClient, type KadoaClientConfig, type KadoaErrorCode, type KadoaEvent, KadoaEventEmitter, KadoaHttpException, KadoaSdkException };
|