@kadoa/node-sdk 0.1.2 → 0.3.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 +7 -6
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +11 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,14 +5,13 @@ 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
|
|
|
@@ -99,6 +98,9 @@ Returns an SDK instance with:
|
|
|
99
98
|
- `onEvent()`: Subscribe to events
|
|
100
99
|
- `offEvent()`: Unsubscribe from events
|
|
101
100
|
|
|
101
|
+
### dispose(sdk)
|
|
102
|
+
Releases resources and removes all event listeners.
|
|
103
|
+
|
|
102
104
|
### runExtraction(sdk, options)
|
|
103
105
|
- `urls`: Array of URLs to extract from
|
|
104
106
|
- `name`: Workflow name
|
|
@@ -110,8 +112,7 @@ See [examples directory](https://github.com/kadoa-org/kadoa-sdks/tree/main/examp
|
|
|
110
112
|
|
|
111
113
|
## Requirements
|
|
112
114
|
|
|
113
|
-
- Node.js
|
|
114
|
-
- TypeScript 5+ (for TypeScript projects)
|
|
115
|
+
- Node.js 22+
|
|
115
116
|
|
|
116
117
|
## License
|
|
117
118
|
|
package/dist/index.d.mts
CHANGED
|
@@ -848,7 +848,7 @@ declare function initializeSdk(config: KadoaConfig): KadoaSDK;
|
|
|
848
848
|
* @example
|
|
849
849
|
* ```typescript
|
|
850
850
|
* const sdkInstance = initializeSdk({ apiKey, enableEvents: true });
|
|
851
|
-
* // ... use the
|
|
851
|
+
* // ... use the sdk
|
|
852
852
|
* dispose(sdkInstance); // Clean up when done
|
|
853
853
|
* ```
|
|
854
854
|
*/
|
|
@@ -864,6 +864,7 @@ interface ExtractionConfig {
|
|
|
864
864
|
};
|
|
865
865
|
pollingInterval: number;
|
|
866
866
|
maxWaitTime: number;
|
|
867
|
+
maxRecords: number;
|
|
867
868
|
}
|
|
868
869
|
type ExtractionOptions = {
|
|
869
870
|
urls: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -848,7 +848,7 @@ declare function initializeSdk(config: KadoaConfig): KadoaSDK;
|
|
|
848
848
|
* @example
|
|
849
849
|
* ```typescript
|
|
850
850
|
* const sdkInstance = initializeSdk({ apiKey, enableEvents: true });
|
|
851
|
-
* // ... use the
|
|
851
|
+
* // ... use the sdk
|
|
852
852
|
* dispose(sdkInstance); // Clean up when done
|
|
853
853
|
* ```
|
|
854
854
|
*/
|
|
@@ -864,6 +864,7 @@ interface ExtractionConfig {
|
|
|
864
864
|
};
|
|
865
865
|
pollingInterval: number;
|
|
866
866
|
maxWaitTime: number;
|
|
867
|
+
maxRecords: number;
|
|
867
868
|
}
|
|
868
869
|
type ExtractionOptions = {
|
|
869
870
|
urls: string[];
|
package/dist/index.js
CHANGED
|
@@ -156,9 +156,8 @@ var DEFAULT_OPTIONS = {
|
|
|
156
156
|
navigationMode: "single-page",
|
|
157
157
|
location: { type: "auto" },
|
|
158
158
|
name: "Untitled Workflow",
|
|
159
|
-
|
|
159
|
+
maxRecords: 99999
|
|
160
160
|
};
|
|
161
|
-
var MAX_DATA_LIMIT = 99999;
|
|
162
161
|
var TERMINAL_RUN_STATES = /* @__PURE__ */ new Set([
|
|
163
162
|
"FINISHED",
|
|
164
163
|
"SUCCESS",
|
|
@@ -1872,11 +1871,11 @@ var Configuration = class {
|
|
|
1872
1871
|
|
|
1873
1872
|
// src/api-client.ts
|
|
1874
1873
|
var workflowsApiCache = /* @__PURE__ */ new WeakMap();
|
|
1875
|
-
function getWorkflowsApi(
|
|
1876
|
-
let api = workflowsApiCache.get(
|
|
1874
|
+
function getWorkflowsApi(sdk) {
|
|
1875
|
+
let api = workflowsApiCache.get(sdk);
|
|
1877
1876
|
if (!api) {
|
|
1878
|
-
api = new WorkflowsApi(
|
|
1879
|
-
workflowsApiCache.set(
|
|
1877
|
+
api = new WorkflowsApi(sdk.configuration, sdk.baseUrl, sdk.axiosInstance);
|
|
1878
|
+
workflowsApiCache.set(sdk, api);
|
|
1880
1879
|
}
|
|
1881
1880
|
return api;
|
|
1882
1881
|
}
|
|
@@ -1982,10 +1981,10 @@ async function handleErrorResponse(response, url, link) {
|
|
|
1982
1981
|
}
|
|
1983
1982
|
);
|
|
1984
1983
|
}
|
|
1985
|
-
async function fetchEntityFields(
|
|
1984
|
+
async function fetchEntityFields(sdk, options) {
|
|
1986
1985
|
validateEntityOptions(options);
|
|
1987
|
-
const url = new URL(ENTITY_API_ENDPOINT,
|
|
1988
|
-
const headers = await buildRequestHeaders(
|
|
1986
|
+
const url = new URL(ENTITY_API_ENDPOINT, sdk.baseUrl || DEFAULT_API_BASE_URL);
|
|
1987
|
+
const headers = await buildRequestHeaders(sdk.configuration);
|
|
1989
1988
|
const requestBody = options;
|
|
1990
1989
|
let response;
|
|
1991
1990
|
try {
|
|
@@ -2048,7 +2047,7 @@ async function createWorkflow(sdkInstance, config) {
|
|
|
2048
2047
|
name: config.name,
|
|
2049
2048
|
fields: config.fields,
|
|
2050
2049
|
bypassPreview: true,
|
|
2051
|
-
limit:
|
|
2050
|
+
limit: config.maxRecords,
|
|
2052
2051
|
tags: ["sdk"]
|
|
2053
2052
|
};
|
|
2054
2053
|
try {
|
|
@@ -2155,11 +2154,9 @@ async function runExtraction(sdkInstance, options) {
|
|
|
2155
2154
|
}
|
|
2156
2155
|
);
|
|
2157
2156
|
const workflowId = await createWorkflow(sdkInstance, {
|
|
2158
|
-
urls: config.urls,
|
|
2159
|
-
navigationMode: config.navigationMode,
|
|
2160
2157
|
entity: entityPrediction.entity,
|
|
2161
2158
|
fields: entityPrediction.fields,
|
|
2162
|
-
|
|
2159
|
+
...config
|
|
2163
2160
|
});
|
|
2164
2161
|
sdkInstance.emit(
|
|
2165
2162
|
"extraction:started",
|
|
@@ -2171,6 +2168,7 @@ async function runExtraction(sdkInstance, options) {
|
|
|
2171
2168
|
"extraction"
|
|
2172
2169
|
);
|
|
2173
2170
|
const workflow = await waitForWorkflowCompletion(sdkInstance, workflowId, {
|
|
2171
|
+
...config,
|
|
2174
2172
|
pollingInterval: config.pollingInterval,
|
|
2175
2173
|
maxWaitTime: config.maxWaitTime
|
|
2176
2174
|
});
|