@dealcrawl/sdk 2.7.0 → 2.10.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 +370 -83
- package/dist/index.d.mts +131 -6
- package/dist/index.d.ts +131 -6
- package/dist/index.js +21 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -473,12 +473,17 @@ async function request(ctx, path, options = {}) {
|
|
|
473
473
|
currentController = null;
|
|
474
474
|
};
|
|
475
475
|
try {
|
|
476
|
+
const headers = {
|
|
477
|
+
"Content-Type": "application/json"
|
|
478
|
+
};
|
|
479
|
+
if (ctx.apiKey) {
|
|
480
|
+
headers["Authorization"] = `Bearer ${ctx.apiKey}`;
|
|
481
|
+
} else if (ctx.clientId) {
|
|
482
|
+
headers["X-Client-ID"] = ctx.clientId;
|
|
483
|
+
}
|
|
476
484
|
const response = await fetch(url, {
|
|
477
485
|
method,
|
|
478
|
-
headers
|
|
479
|
-
"Content-Type": "application/json",
|
|
480
|
-
Authorization: `Bearer ${ctx.apiKey}`
|
|
481
|
-
},
|
|
486
|
+
headers,
|
|
482
487
|
body: body ? JSON.stringify(body) : void 0,
|
|
483
488
|
signal: controller.signal
|
|
484
489
|
});
|
|
@@ -2893,9 +2898,12 @@ var DealCrawl = class {
|
|
|
2893
2898
|
*
|
|
2894
2899
|
* @example
|
|
2895
2900
|
* ```ts
|
|
2896
|
-
* //
|
|
2901
|
+
* // With API key
|
|
2897
2902
|
* const client = new DealCrawl({ apiKey: "sk_xxx" });
|
|
2898
2903
|
*
|
|
2904
|
+
* // With Client ID (for internal calls)
|
|
2905
|
+
* const client = new DealCrawl({ clientId: "uuid-xxx" });
|
|
2906
|
+
*
|
|
2899
2907
|
* // Full config
|
|
2900
2908
|
* const client = new DealCrawl({
|
|
2901
2909
|
* apiKey: "sk_xxx",
|
|
@@ -2908,11 +2916,17 @@ var DealCrawl = class {
|
|
|
2908
2916
|
* ```
|
|
2909
2917
|
*/
|
|
2910
2918
|
constructor(config) {
|
|
2911
|
-
|
|
2912
|
-
|
|
2919
|
+
const hasApiKey = config.apiKey && config.apiKey.trim();
|
|
2920
|
+
const hasClientId = config.clientId && config.clientId.trim();
|
|
2921
|
+
if (!hasApiKey && !hasClientId) {
|
|
2922
|
+
throw new Error("Either API key or Client ID is required");
|
|
2923
|
+
}
|
|
2924
|
+
if (hasApiKey && hasClientId) {
|
|
2925
|
+
throw new Error("Provide either API key OR Client ID, not both");
|
|
2913
2926
|
}
|
|
2914
2927
|
this.ctx = {
|
|
2915
2928
|
apiKey: config.apiKey,
|
|
2929
|
+
clientId: config.clientId,
|
|
2916
2930
|
baseUrl: config.baseUrl ?? DEFAULT_CONFIG.baseUrl,
|
|
2917
2931
|
timeout: config.timeout ?? DEFAULT_CONFIG.timeout,
|
|
2918
2932
|
maxRetries: config.maxRetries ?? DEFAULT_CONFIG.maxRetries,
|