@land-catalyst/batch-data-sdk 1.3.0 → 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/builders/builders.js +6 -5
- package/dist/client/client.d.ts +27 -6
- package/dist/client/client.js +16 -45
- package/dist/core/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2276,7 +2276,9 @@ class PropertySubscriptionBuilder extends RequestWithSearchCriteriaBuilder {
|
|
|
2276
2276
|
static from(request) {
|
|
2277
2277
|
const builder = new PropertySubscriptionBuilder();
|
|
2278
2278
|
builder.searchCriteria(request.searchCriteria);
|
|
2279
|
-
|
|
2279
|
+
if (request.deliveryConfig) {
|
|
2280
|
+
builder.deliveryConfig(request.deliveryConfig);
|
|
2281
|
+
}
|
|
2280
2282
|
if (request.options) {
|
|
2281
2283
|
builder.options(request.options);
|
|
2282
2284
|
}
|
|
@@ -2297,12 +2299,11 @@ class PropertySubscriptionBuilder extends RequestWithSearchCriteriaBuilder {
|
|
|
2297
2299
|
}
|
|
2298
2300
|
build() {
|
|
2299
2301
|
this.validateSearchCriteria();
|
|
2300
|
-
if (!this.criteria.deliveryConfig) {
|
|
2301
|
-
throw new Error("Delivery configuration is required");
|
|
2302
|
-
}
|
|
2303
2302
|
const request = {
|
|
2304
2303
|
searchCriteria: this.criteria.searchCriteria,
|
|
2305
|
-
|
|
2304
|
+
...(this.criteria.deliveryConfig && {
|
|
2305
|
+
deliveryConfig: this.criteria.deliveryConfig,
|
|
2306
|
+
}),
|
|
2306
2307
|
};
|
|
2307
2308
|
return this.buildOptionsIntoRequest(request);
|
|
2308
2309
|
}
|
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 } from "../core/types";
|
|
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.).
|
|
@@ -98,6 +98,10 @@ export interface AsyncWebhookConfiguration {
|
|
|
98
98
|
*/
|
|
99
99
|
propertySubscription?: AsyncWebhookUrls;
|
|
100
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Event Hub configuration for async API requests
|
|
103
|
+
* Allows specifying Event Hub config per endpoint type, with fallback to defaults
|
|
104
|
+
*/
|
|
101
105
|
/**
|
|
102
106
|
* BatchData API Client Options
|
|
103
107
|
*/
|
|
@@ -129,6 +133,22 @@ export interface BatchDataClientOptions {
|
|
|
129
133
|
* Allows specifying webhook URLs per endpoint type, with fallback to defaults
|
|
130
134
|
*/
|
|
131
135
|
webhooks?: AsyncWebhookConfiguration;
|
|
136
|
+
/**
|
|
137
|
+
* Optional default delivery configuration for property subscriptions
|
|
138
|
+
* If provided, this will be used when a subscription request doesn't specify deliveryConfig
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const client = new BatchDataClient({
|
|
143
|
+
* apiKey: "...",
|
|
144
|
+
* defaultDeliveryConfig: {
|
|
145
|
+
* type: "webhook",
|
|
146
|
+
* url: "https://example.com/webhook",
|
|
147
|
+
* }
|
|
148
|
+
* });
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
defaultDeliveryConfig?: DeliveryConfig;
|
|
132
152
|
/**
|
|
133
153
|
* Optional default PropertyLookupOptions to apply to all requests
|
|
134
154
|
* These defaults are merged with request-specific options, with request options taking precedence
|
|
@@ -178,6 +198,7 @@ export declare class BatchDataClient implements IBatchDataClient {
|
|
|
178
198
|
protected readonly axiosInstance: AxiosInstance;
|
|
179
199
|
protected readonly logger: ILogger;
|
|
180
200
|
private readonly webhooks?;
|
|
201
|
+
private readonly defaultDeliveryConfig?;
|
|
181
202
|
private readonly defaultOptions?;
|
|
182
203
|
private readonly maxTake?;
|
|
183
204
|
constructor(options: BatchDataClientOptions);
|
|
@@ -231,14 +252,14 @@ export declare class BatchDataClient implements IBatchDataClient {
|
|
|
231
252
|
*/
|
|
232
253
|
private applyDefaultOptions;
|
|
233
254
|
/**
|
|
234
|
-
* Apply default
|
|
235
|
-
*
|
|
236
|
-
* they will be used for property subscriptions that don't explicitly specify webhook URLs.
|
|
255
|
+
* Apply default delivery configuration to a property subscription request.
|
|
256
|
+
* If deliveryConfig is not set in the request, use defaultDeliveryConfig if available.
|
|
237
257
|
*
|
|
238
258
|
* @param request The property subscription request to modify
|
|
239
|
-
* @returns The request with
|
|
259
|
+
* @returns The request with delivery config applied (if needed)
|
|
260
|
+
* @throws Error if deliveryConfig is not set and no default is available
|
|
240
261
|
*/
|
|
241
|
-
private
|
|
262
|
+
private applyDeliveryConfigDefaults;
|
|
242
263
|
/**
|
|
243
264
|
* Add a request middleware function that executes before requests are sent.
|
|
244
265
|
* Useful for adding headers, logging, metrics, etc.
|
package/dist/client/client.js
CHANGED
|
@@ -24,6 +24,7 @@ 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.defaultDeliveryConfig = options.defaultDeliveryConfig;
|
|
27
28
|
this.defaultOptions = options.defaultOptions;
|
|
28
29
|
this.maxTake = options.maxTake;
|
|
29
30
|
this.axiosInstance = axios_1.default.create({
|
|
@@ -288,53 +289,23 @@ class BatchDataClient {
|
|
|
288
289
|
};
|
|
289
290
|
}
|
|
290
291
|
/**
|
|
291
|
-
* Apply default
|
|
292
|
-
*
|
|
293
|
-
* they will be used for property subscriptions that don't explicitly specify webhook URLs.
|
|
292
|
+
* Apply default delivery configuration to a property subscription request.
|
|
293
|
+
* If deliveryConfig is not set in the request, use defaultDeliveryConfig if available.
|
|
294
294
|
*
|
|
295
295
|
* @param request The property subscription request to modify
|
|
296
|
-
* @returns The request with
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
webhookUrl = this.webhooks.propertySubscription.url;
|
|
305
|
-
errorWebhookUrl = this.webhooks.propertySubscription.errorUrl;
|
|
306
|
-
}
|
|
307
|
-
// Fall back to default webhook config
|
|
308
|
-
if (!webhookUrl && this.webhooks?.default) {
|
|
309
|
-
webhookUrl = this.webhooks.default.url;
|
|
310
|
-
errorWebhookUrl = errorWebhookUrl || this.webhooks.default.errorUrl;
|
|
311
|
-
}
|
|
312
|
-
// If no webhook URLs are configured, return original request
|
|
313
|
-
if (!webhookUrl && !errorWebhookUrl) {
|
|
314
|
-
return request;
|
|
315
|
-
}
|
|
316
|
-
// If deliveryConfig is not set or is not a webhook type, create/update it
|
|
317
|
-
const deliveryConfig = request.deliveryConfig || {
|
|
318
|
-
type: "webhook",
|
|
319
|
-
};
|
|
320
|
-
// Only apply defaults if deliveryConfig is a webhook type
|
|
321
|
-
if (deliveryConfig.type === "webhook") {
|
|
322
|
-
// Apply webhook URL if not already set
|
|
323
|
-
if (!deliveryConfig.url && webhookUrl) {
|
|
324
|
-
deliveryConfig.url = webhookUrl;
|
|
325
|
-
}
|
|
326
|
-
// Apply error webhook URL if not already set
|
|
327
|
-
if (!deliveryConfig.errorUrl && errorWebhookUrl) {
|
|
328
|
-
deliveryConfig.errorUrl = errorWebhookUrl;
|
|
296
|
+
* @returns The request with delivery config applied (if needed)
|
|
297
|
+
* @throws Error if deliveryConfig is not set and no default is available
|
|
298
|
+
*/
|
|
299
|
+
applyDeliveryConfigDefaults(request) {
|
|
300
|
+
// If deliveryConfig is not set, use defaultDeliveryConfig
|
|
301
|
+
if (!request.deliveryConfig) {
|
|
302
|
+
if (this.defaultDeliveryConfig) {
|
|
303
|
+
return { ...request, deliveryConfig: this.defaultDeliveryConfig };
|
|
329
304
|
}
|
|
305
|
+
throw new Error("Property subscription requires delivery configuration. " +
|
|
306
|
+
"Please provide deliveryConfig in the request, or configure defaultDeliveryConfig in BatchDataClient options.");
|
|
330
307
|
}
|
|
331
|
-
|
|
332
|
-
return {
|
|
333
|
-
...request,
|
|
334
|
-
deliveryConfig: {
|
|
335
|
-
...deliveryConfig,
|
|
336
|
-
},
|
|
337
|
-
};
|
|
308
|
+
return request;
|
|
338
309
|
}
|
|
339
310
|
/**
|
|
340
311
|
* Add a request middleware function that executes before requests are sent.
|
|
@@ -449,8 +420,8 @@ class BatchDataClient {
|
|
|
449
420
|
*/
|
|
450
421
|
async createPropertySubscription(request) {
|
|
451
422
|
const url = `${this.v2BaseUrl}/property-subscription`;
|
|
452
|
-
// Apply default
|
|
453
|
-
let requestWithDefaults = this.
|
|
423
|
+
// Apply default delivery config (Event Hub preferred over webhooks)
|
|
424
|
+
let requestWithDefaults = this.applyDeliveryConfigDefaults(request);
|
|
454
425
|
// Apply defaults and limits (including maxTake)
|
|
455
426
|
requestWithDefaults =
|
|
456
427
|
this.applySearchRequestDefaultsAndLimits(requestWithDefaults);
|
package/dist/core/types.d.ts
CHANGED
|
@@ -479,7 +479,7 @@ export interface DeliveryConfig {
|
|
|
479
479
|
* Property subscription request payload
|
|
480
480
|
*/
|
|
481
481
|
export interface PropertySubscriptionRequest extends RequestWithSearchCriteria {
|
|
482
|
-
deliveryConfig
|
|
482
|
+
deliveryConfig?: DeliveryConfig;
|
|
483
483
|
}
|
|
484
484
|
/**
|
|
485
485
|
* Property subscription response
|
package/package.json
CHANGED