@land-catalyst/batch-data-sdk 1.3.1 → 1.3.2
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/dist/client/client.d.ts +4 -29
- package/dist/client/client.js +7 -95
- package/package.json +1 -1
package/dist/client/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance, AxiosResponse, AxiosError, InternalAxiosRequestConfig } from "axios";
|
|
2
2
|
import { IBatchDataClient } from "./client.interface";
|
|
3
3
|
import { ILogger } from "../core/logger.interface";
|
|
4
|
-
import { PropertySubscriptionRequest, PropertySubscriptionResponse, PropertyCountRequest, PropertySearchRequest, PropertySearchResponse, PropertyLookupOptions, AddressVerifyRequest, AddressVerifyResponse, AddressAutocompleteRequest, AddressAutocompleteResponse, AddressGeocodeRequest, AddressGeocodeResponse, AddressReverseGeocodeRequest, AddressReverseGeocodeResponse, PropertyLookupRequest, PropertyLookupResponse, PropertyLookupAsyncRequest, PropertyLookupAsyncResponse, PropertySearchAsyncRequest, PropertySearchAsyncResponse, PropertySkipTraceRequest, PropertySkipTraceResponse, PropertySkipTraceAsyncRequest, PropertySkipTraceAsyncResponse, PhoneVerificationRequest, PhoneVerificationResponse, PhoneVerificationAsyncRequest, PhoneVerificationAsyncResponse, PhoneDNCRequest, PhoneDNCResponse, PhoneDNCAsyncRequest, PhoneDNCAsyncResponse, PhoneTCPARequest, PhoneTCPAResponse, PhoneTCPAAsyncRequest, PhoneTCPAAsyncResponse, GetPropertySubscriptionsResponse, GetPropertySubscriptionDetailResponse, DeletePropertySubscriptionResponse, PropertyPermitRequest, PropertyPermitResponse, PropertySkipTraceV3Request, PropertySkipTraceV3Response, PropertySkipTraceV3AsyncRequest, PropertySkipTraceV3AsyncResponse,
|
|
4
|
+
import { PropertySubscriptionRequest, PropertySubscriptionResponse, PropertyCountRequest, PropertySearchRequest, PropertySearchResponse, PropertyLookupOptions, AddressVerifyRequest, AddressVerifyResponse, AddressAutocompleteRequest, AddressAutocompleteResponse, AddressGeocodeRequest, AddressGeocodeResponse, AddressReverseGeocodeRequest, AddressReverseGeocodeResponse, PropertyLookupRequest, PropertyLookupResponse, PropertyLookupAsyncRequest, PropertyLookupAsyncResponse, PropertySearchAsyncRequest, PropertySearchAsyncResponse, PropertySkipTraceRequest, PropertySkipTraceResponse, PropertySkipTraceAsyncRequest, PropertySkipTraceAsyncResponse, PhoneVerificationRequest, PhoneVerificationResponse, PhoneVerificationAsyncRequest, PhoneVerificationAsyncResponse, PhoneDNCRequest, PhoneDNCResponse, PhoneDNCAsyncRequest, PhoneDNCAsyncResponse, PhoneTCPARequest, PhoneTCPAResponse, PhoneTCPAAsyncRequest, PhoneTCPAAsyncResponse, GetPropertySubscriptionsResponse, GetPropertySubscriptionDetailResponse, DeletePropertySubscriptionResponse, PropertyPermitRequest, PropertyPermitResponse, PropertySkipTraceV3Request, PropertySkipTraceV3Response, PropertySkipTraceV3AsyncRequest, PropertySkipTraceV3AsyncResponse, DeliveryConfig } from "../core/types";
|
|
5
5
|
/**
|
|
6
6
|
* Middleware function that executes before an HTTP request is sent.
|
|
7
7
|
* Can modify the request config or perform side effects (logging, metrics, etc.).
|
|
@@ -102,16 +102,6 @@ export interface AsyncWebhookConfiguration {
|
|
|
102
102
|
* Event Hub configuration for async API requests
|
|
103
103
|
* Allows specifying Event Hub config per endpoint type, with fallback to defaults
|
|
104
104
|
*/
|
|
105
|
-
export interface AsyncEventHubConfiguration {
|
|
106
|
-
/**
|
|
107
|
-
* Default Event Hub config used as fallback for all async endpoints
|
|
108
|
-
*/
|
|
109
|
-
default?: EventHubConfig;
|
|
110
|
-
/**
|
|
111
|
-
* Event Hub config for property subscription requests
|
|
112
|
-
*/
|
|
113
|
-
propertySubscription?: EventHubConfig;
|
|
114
|
-
}
|
|
115
105
|
/**
|
|
116
106
|
* BatchData API Client Options
|
|
117
107
|
*/
|
|
@@ -143,15 +133,9 @@ export interface BatchDataClientOptions {
|
|
|
143
133
|
* Allows specifying webhook URLs per endpoint type, with fallback to defaults
|
|
144
134
|
*/
|
|
145
135
|
webhooks?: AsyncWebhookConfiguration;
|
|
146
|
-
/**
|
|
147
|
-
* Optional Event Hub configuration for async requests
|
|
148
|
-
* Allows specifying Event Hub config per endpoint type, with fallback to defaults
|
|
149
|
-
*/
|
|
150
|
-
eventHubs?: AsyncEventHubConfiguration;
|
|
151
136
|
/**
|
|
152
137
|
* Optional default delivery configuration for property subscriptions
|
|
153
138
|
* If provided, this will be used when a subscription request doesn't specify deliveryConfig
|
|
154
|
-
* Takes precedence over webhooks and eventHubs configurations
|
|
155
139
|
*
|
|
156
140
|
* @example
|
|
157
141
|
* ```typescript
|
|
@@ -214,7 +198,6 @@ export declare class BatchDataClient implements IBatchDataClient {
|
|
|
214
198
|
protected readonly axiosInstance: AxiosInstance;
|
|
215
199
|
protected readonly logger: ILogger;
|
|
216
200
|
private readonly webhooks?;
|
|
217
|
-
private readonly eventHubs?;
|
|
218
201
|
private readonly defaultDeliveryConfig?;
|
|
219
202
|
private readonly defaultOptions?;
|
|
220
203
|
private readonly maxTake?;
|
|
@@ -269,20 +252,12 @@ export declare class BatchDataClient implements IBatchDataClient {
|
|
|
269
252
|
*/
|
|
270
253
|
private applyDefaultOptions;
|
|
271
254
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* @returns Delivery config from fallbacks, or undefined if none available
|
|
276
|
-
*/
|
|
277
|
-
private createDeliveryConfigFromFallbacks;
|
|
278
|
-
/**
|
|
279
|
-
* Apply default delivery configuration (Event Hub or webhook) to a property subscription request.
|
|
280
|
-
* Event Hub takes precedence over webhooks if both are configured.
|
|
281
|
-
* If deliveryConfig is not set, it will be created based on available configs (Event Hub preferred).
|
|
255
|
+
* Apply default delivery configuration to a property subscription request.
|
|
256
|
+
* If deliveryConfig is not set in the request, use defaultDeliveryConfig if available.
|
|
282
257
|
*
|
|
283
258
|
* @param request The property subscription request to modify
|
|
284
259
|
* @returns The request with delivery config applied (if needed)
|
|
285
|
-
* @throws Error if deliveryConfig
|
|
260
|
+
* @throws Error if deliveryConfig is not set and no default is available
|
|
286
261
|
*/
|
|
287
262
|
private applyDeliveryConfigDefaults;
|
|
288
263
|
/**
|
package/dist/client/client.js
CHANGED
|
@@ -24,7 +24,6 @@ class BatchDataClient {
|
|
|
24
24
|
this.v3BaseUrl = options.v3BaseUrl || "https://api.batchdata.com/api/v3";
|
|
25
25
|
this.logger = options.logger || new logger_interface_1.ConsoleLogger();
|
|
26
26
|
this.webhooks = options.webhooks;
|
|
27
|
-
this.eventHubs = options.eventHubs;
|
|
28
27
|
this.defaultDeliveryConfig = options.defaultDeliveryConfig;
|
|
29
28
|
this.defaultOptions = options.defaultOptions;
|
|
30
29
|
this.maxTake = options.maxTake;
|
|
@@ -290,108 +289,21 @@ class BatchDataClient {
|
|
|
290
289
|
};
|
|
291
290
|
}
|
|
292
291
|
/**
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
* @returns Delivery config from fallbacks, or undefined if none available
|
|
297
|
-
*/
|
|
298
|
-
createDeliveryConfigFromFallbacks() {
|
|
299
|
-
// Explicit defaultDeliveryConfig takes highest precedence
|
|
300
|
-
if (this.defaultDeliveryConfig) {
|
|
301
|
-
return this.defaultDeliveryConfig;
|
|
302
|
-
}
|
|
303
|
-
// Determine which Event Hub config to use (property subscription-specific first, then default)
|
|
304
|
-
const eventHubConfig = this.eventHubs?.propertySubscription ?? this.eventHubs?.default;
|
|
305
|
-
// Determine which webhook URLs to use
|
|
306
|
-
let webhookUrl;
|
|
307
|
-
let errorWebhookUrl;
|
|
308
|
-
// First, try property subscription-specific webhook config
|
|
309
|
-
if (this.webhooks?.propertySubscription) {
|
|
310
|
-
webhookUrl = this.webhooks.propertySubscription.url;
|
|
311
|
-
errorWebhookUrl = this.webhooks.propertySubscription.errorUrl;
|
|
312
|
-
}
|
|
313
|
-
// Fall back to default webhook config
|
|
314
|
-
if (!webhookUrl && this.webhooks?.default) {
|
|
315
|
-
webhookUrl = this.webhooks.default.url;
|
|
316
|
-
errorWebhookUrl = errorWebhookUrl || this.webhooks.default.errorUrl;
|
|
317
|
-
}
|
|
318
|
-
// Event Hub takes precedence over webhooks
|
|
319
|
-
if (eventHubConfig) {
|
|
320
|
-
return {
|
|
321
|
-
type: "event-hub",
|
|
322
|
-
eventHub: eventHubConfig,
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
if (webhookUrl || errorWebhookUrl) {
|
|
326
|
-
return {
|
|
327
|
-
type: "webhook",
|
|
328
|
-
...(webhookUrl && { url: webhookUrl }),
|
|
329
|
-
...(errorWebhookUrl && { errorUrl: errorWebhookUrl }),
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
return undefined;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Apply default delivery configuration (Event Hub or webhook) to a property subscription request.
|
|
336
|
-
* Event Hub takes precedence over webhooks if both are configured.
|
|
337
|
-
* If deliveryConfig is not set, it will be created based on available configs (Event Hub preferred).
|
|
292
|
+
* Apply default delivery configuration to a property subscription request.
|
|
293
|
+
* If deliveryConfig is not set in the request, use defaultDeliveryConfig if available.
|
|
338
294
|
*
|
|
339
295
|
* @param request The property subscription request to modify
|
|
340
296
|
* @returns The request with delivery config applied (if needed)
|
|
341
|
-
* @throws Error if deliveryConfig
|
|
297
|
+
* @throws Error if deliveryConfig is not set and no default is available
|
|
342
298
|
*/
|
|
343
299
|
applyDeliveryConfigDefaults(request) {
|
|
344
|
-
|
|
345
|
-
// If deliveryConfig is not set, create it from fallbacks
|
|
300
|
+
// If deliveryConfig is not set, use defaultDeliveryConfig
|
|
346
301
|
if (!request.deliveryConfig) {
|
|
347
|
-
if (
|
|
348
|
-
return { ...request, deliveryConfig:
|
|
302
|
+
if (this.defaultDeliveryConfig) {
|
|
303
|
+
return { ...request, deliveryConfig: this.defaultDeliveryConfig };
|
|
349
304
|
}
|
|
350
|
-
// If no fallback config is available, throw an error
|
|
351
305
|
throw new Error("Property subscription requires delivery configuration. " +
|
|
352
|
-
"Please provide deliveryConfig in the request, or configure
|
|
353
|
-
}
|
|
354
|
-
const deliveryConfig = request.deliveryConfig;
|
|
355
|
-
// If type is event-hub, use request's eventHub or fallback's eventHub
|
|
356
|
-
if (deliveryConfig.type === "event-hub") {
|
|
357
|
-
const eventHubConfig = deliveryConfig.eventHub ??
|
|
358
|
-
(fallbackConfig?.type === "event-hub"
|
|
359
|
-
? fallbackConfig.eventHub
|
|
360
|
-
: undefined);
|
|
361
|
-
if (!eventHubConfig) {
|
|
362
|
-
throw new Error("Property subscription requires Event Hub configuration, but none is available. " +
|
|
363
|
-
"Please provide eventHub in deliveryConfig, or configure eventHubs in BatchDataClient options.");
|
|
364
|
-
}
|
|
365
|
-
if (!deliveryConfig.eventHub) {
|
|
366
|
-
return {
|
|
367
|
-
...request,
|
|
368
|
-
deliveryConfig: {
|
|
369
|
-
...deliveryConfig,
|
|
370
|
-
eventHub: eventHubConfig,
|
|
371
|
-
},
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
// If type is webhook, use request's URLs or fallback's URLs
|
|
376
|
-
if (deliveryConfig.type === "webhook") {
|
|
377
|
-
const webhookUrl = deliveryConfig.url ??
|
|
378
|
-
(fallbackConfig?.type === "webhook" ? fallbackConfig.url : undefined);
|
|
379
|
-
const errorWebhookUrl = deliveryConfig.errorUrl ??
|
|
380
|
-
(fallbackConfig?.type === "webhook"
|
|
381
|
-
? fallbackConfig.errorUrl
|
|
382
|
-
: undefined);
|
|
383
|
-
if ((!deliveryConfig.url && webhookUrl) ||
|
|
384
|
-
(!deliveryConfig.errorUrl && errorWebhookUrl)) {
|
|
385
|
-
return {
|
|
386
|
-
...request,
|
|
387
|
-
deliveryConfig: {
|
|
388
|
-
...deliveryConfig,
|
|
389
|
-
...(webhookUrl && !deliveryConfig.url && { url: webhookUrl }),
|
|
390
|
-
...(errorWebhookUrl &&
|
|
391
|
-
!deliveryConfig.errorUrl && { errorUrl: errorWebhookUrl }),
|
|
392
|
-
},
|
|
393
|
-
};
|
|
394
|
-
}
|
|
306
|
+
"Please provide deliveryConfig in the request, or configure defaultDeliveryConfig in BatchDataClient options.");
|
|
395
307
|
}
|
|
396
308
|
return request;
|
|
397
309
|
}
|
package/package.json
CHANGED