@land-catalyst/batch-data-sdk 1.2.10 → 1.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/dist/builders/builders.d.ts +79 -20
- package/dist/builders/builders.js +81 -95
- package/dist/client/client.d.ts +62 -1
- package/dist/client/client.js +97 -9
- package/dist/core/types.d.ts +57 -14
- package/package.json +2 -2
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* .build();
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
import { StringFilter, NumericRangeFilter, DateRangeFilter, GeoLocationDistance, GeoLocationBoundingBox, GeoLocationPolygon, AddressSearchCriteria, AssessmentSearchCriteria, BuildingSearchCriteria, CompAddressSearchCriteria, DemographicsSearchCriteria, ForeclosureSearchCriteria, GeneralSearchCriteria, IdsSearchCriteria, IntelSearchCriteria, InvoluntaryLienSearchCriteria, LegalSearchCriteria, ListingSearchCriteria, LotSearchCriteria, OpenLienSearchCriteria, OwnerSearchCriteria, PermitSearchCriteria, PropertyOwnerProfileSearchCriteria, SaleSearchCriteria, TaxSearchCriteria, ValuationSearchCriteria, OrSearchCriteria, SearchCriteria, DeliveryConfig, EventHubConfig, PropertySubscriptionRequest, QuickListValueWithNot, PropertyLookupRequest, PropertyLookupRequestItem, PropertyLookupRequestAddress, PropertyLookupOptions, PropertyPermitRequest, PropertyCountRequest, PropertySearchRequest, PropertySearchAsyncRequest, PropertyLookupAsyncRequest, GeoPoint, AirConditioningSource, BasementType, BuildingClass, BuildingCondition, BuildingQuality, ConstructionType, Driveway, ExteriorWalls, FloorCover, Garage, HeatSource, HeatingFuelType, InteriorWalls, Patio, Pool, Porch, RoofCover, RoofType, Sewer, Style, WaterService, Features, HomeownerRenter, BusinessOwner, Gender, Investments, DemographicsValue, ReligiousAffiliation, ForeclosureStatus, PropertyTypeCategory, PropertyTypeDetail, LienType, LienTypeCode, LoanType, OwnerStatusType, LastSaleDocumentType, ZoningCode } from "../core/types";
|
|
19
|
+
import { StringFilter, NumericRangeFilter, DateRangeFilter, GeoLocationDistance, GeoLocationBoundingBox, GeoLocationPolygon, AddressSearchCriteria, AssessmentSearchCriteria, BuildingSearchCriteria, CompAddressSearchCriteria, DemographicsSearchCriteria, ForeclosureSearchCriteria, GeneralSearchCriteria, IdsSearchCriteria, IntelSearchCriteria, InvoluntaryLienSearchCriteria, LegalSearchCriteria, ListingSearchCriteria, LotSearchCriteria, OpenLienSearchCriteria, OwnerSearchCriteria, PermitSearchCriteria, PropertyOwnerProfileSearchCriteria, SaleSearchCriteria, TaxSearchCriteria, ValuationSearchCriteria, OrSearchCriteria, SearchCriteria, DeliveryConfig, EventHubConfig, PropertySubscriptionRequest, QuickListValueWithNot, PropertyLookupRequest, PropertyLookupRequestItem, PropertyLookupRequestAddress, PropertyLookupOptions, PropertyPermitRequest, PropertyCountRequest, PropertySearchRequest, PropertySearchAsyncRequest, PropertyLookupAsyncRequest, RequestWithLookupOptions, RequestWithSearchCriteria, GeoPoint, AirConditioningSource, BasementType, BuildingClass, BuildingCondition, BuildingQuality, ConstructionType, Driveway, ExteriorWalls, FloorCover, Garage, HeatSource, HeatingFuelType, InteriorWalls, Patio, Pool, Porch, RoofCover, RoofType, Sewer, Style, WaterService, Features, HomeownerRenter, BusinessOwner, Gender, Investments, DemographicsValue, ReligiousAffiliation, ForeclosureStatus, PropertyTypeCategory, PropertyTypeDetail, LienType, LienTypeCode, LoanType, OwnerStatusType, LastSaleDocumentType, ZoningCode } from "../core/types";
|
|
20
20
|
import type { PropertyFieldMetadata } from "../property-field/metadata";
|
|
21
21
|
/**
|
|
22
22
|
* Base interface for all builders
|
|
@@ -145,6 +145,79 @@ declare abstract class BaseBuilder<T> implements Builder<T> {
|
|
|
145
145
|
protected setPropertyWithBuilderClass<K extends keyof T, B extends Builder<T[K]>>(key: K, valueOrConfigurator: T[K] | ((builder: B) => void), BuilderClass: new () => B): this;
|
|
146
146
|
build(): T;
|
|
147
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Base class for builders that work with RequestWithLookupOptions types.
|
|
150
|
+
* Provides the common `options` method implementation.
|
|
151
|
+
*
|
|
152
|
+
* Builders that work with requests that have PropertyLookupOptions should extend
|
|
153
|
+
* this class instead of BaseBuilder directly.
|
|
154
|
+
*/
|
|
155
|
+
export declare abstract class RequestWithLookupOptionsBuilder<T extends RequestWithLookupOptions> extends BaseBuilder<T> {
|
|
156
|
+
/**
|
|
157
|
+
* Set PropertyLookupOptions either directly or via a builder configurator.
|
|
158
|
+
*
|
|
159
|
+
* @param optionsOrConfigurator - Either the direct options object or a configurator function
|
|
160
|
+
* @returns This builder instance for method chaining
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* // Direct value
|
|
165
|
+
* builder.options({ take: 10, skip: 0 });
|
|
166
|
+
*
|
|
167
|
+
* // Builder configurator
|
|
168
|
+
* builder.options((opts) => {
|
|
169
|
+
* opts.take(10).skip(0).skipTrace(true);
|
|
170
|
+
* });
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
options(options: PropertyLookupOptions): this;
|
|
174
|
+
options(configurator: (builder: PropertyLookupOptionsBuilder) => void): this;
|
|
175
|
+
/**
|
|
176
|
+
* Helper method to build options into a request object.
|
|
177
|
+
* This is used by subclasses in their build() methods.
|
|
178
|
+
*
|
|
179
|
+
* @param request - The request object being built
|
|
180
|
+
* @returns The request object with options applied (if any)
|
|
181
|
+
*/
|
|
182
|
+
protected buildOptionsIntoRequest<R extends RequestWithLookupOptions>(request: R): R;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Base class for builders that work with RequestWithSearchCriteria types.
|
|
186
|
+
* Provides the common `searchCriteria` and `options` method implementations.
|
|
187
|
+
*
|
|
188
|
+
* Builders that work with requests that have both searchCriteria and options
|
|
189
|
+
* should extend this class instead of RequestWithLookupOptionsBuilder directly.
|
|
190
|
+
*/
|
|
191
|
+
export declare abstract class RequestWithSearchCriteriaBuilder<T extends RequestWithSearchCriteria> extends RequestWithLookupOptionsBuilder<T> {
|
|
192
|
+
/**
|
|
193
|
+
* Set SearchCriteria either directly or via a builder configurator.
|
|
194
|
+
*
|
|
195
|
+
* @param criteriaOrConfigurator - Either the direct SearchCriteria object or a configurator function
|
|
196
|
+
* @returns This builder instance for method chaining
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* // Direct value
|
|
201
|
+
* builder.searchCriteria({ query: "123 Main St" });
|
|
202
|
+
*
|
|
203
|
+
* // Builder configurator
|
|
204
|
+
* builder.searchCriteria((sc) => {
|
|
205
|
+
* sc.address((addr) => {
|
|
206
|
+
* addr.street("Main St").city("Phoenix").state("AZ");
|
|
207
|
+
* });
|
|
208
|
+
* });
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
searchCriteria(criteria: SearchCriteria): this;
|
|
212
|
+
searchCriteria(configurator: (builder: SearchCriteriaBuilder) => void): this;
|
|
213
|
+
/**
|
|
214
|
+
* Helper method to validate that searchCriteria is present in build() methods.
|
|
215
|
+
* Throws an error if searchCriteria is missing.
|
|
216
|
+
*
|
|
217
|
+
* @throws Error if searchCriteria is not set
|
|
218
|
+
*/
|
|
219
|
+
protected validateSearchCriteria(): void;
|
|
220
|
+
}
|
|
148
221
|
/**
|
|
149
222
|
* Base builder for string filters
|
|
150
223
|
* @template T - Optional union type of allowed string values. Defaults to `string` for backward compatibility.
|
|
@@ -743,10 +816,8 @@ export declare class DeliveryConfigBuilder {
|
|
|
743
816
|
/**
|
|
744
817
|
* Main builder for property subscription requests
|
|
745
818
|
*/
|
|
746
|
-
export declare class PropertySubscriptionBuilder extends
|
|
819
|
+
export declare class PropertySubscriptionBuilder extends RequestWithSearchCriteriaBuilder<PropertySubscriptionRequest> {
|
|
747
820
|
static from(request: PropertySubscriptionRequest): PropertySubscriptionBuilder;
|
|
748
|
-
searchCriteria(criteria: SearchCriteria): this;
|
|
749
|
-
searchCriteria(configurator: (builder: SearchCriteriaBuilder) => void): this;
|
|
750
821
|
deliveryConfig(config: DeliveryConfig): this;
|
|
751
822
|
deliveryConfig(configurator: (builder: DeliveryConfigBuilder) => void): this;
|
|
752
823
|
build(): PropertySubscriptionRequest;
|
|
@@ -805,14 +876,12 @@ export declare class AsyncPropertyLookupOptionsBuilder extends PropertyLookupOpt
|
|
|
805
876
|
/**
|
|
806
877
|
* Builder for property lookup requests
|
|
807
878
|
*/
|
|
808
|
-
export declare class PropertyLookupRequestBuilder extends
|
|
879
|
+
export declare class PropertyLookupRequestBuilder extends RequestWithLookupOptionsBuilder<PropertyLookupRequest> {
|
|
809
880
|
private requestItems;
|
|
810
881
|
static from(request: PropertyLookupRequest): PropertyLookupRequestBuilder;
|
|
811
882
|
items(items: PropertyLookupRequestItem[]): this;
|
|
812
883
|
addItem(item: PropertyLookupRequestItem): this;
|
|
813
884
|
addItemBuilder(builder: PropertyLookupRequestItemBuilder): this;
|
|
814
|
-
options(options: PropertyLookupOptions): this;
|
|
815
|
-
options(configurator: (builder: PropertyLookupOptionsBuilder) => void): this;
|
|
816
885
|
build(): PropertyLookupRequest;
|
|
817
886
|
}
|
|
818
887
|
/**
|
|
@@ -829,36 +898,26 @@ export declare class PropertyCountRequestBuilder extends BaseBuilder<PropertyCou
|
|
|
829
898
|
/**
|
|
830
899
|
* Builder for property search requests
|
|
831
900
|
*/
|
|
832
|
-
export declare class PropertySearchRequestBuilder extends
|
|
901
|
+
export declare class PropertySearchRequestBuilder extends RequestWithSearchCriteriaBuilder<PropertySearchRequest> {
|
|
833
902
|
static from(request: PropertySearchRequest): PropertySearchRequestBuilder;
|
|
834
|
-
searchCriteria(criteria: SearchCriteria): this;
|
|
835
|
-
searchCriteria(configurator: (builder: SearchCriteriaBuilder) => void): this;
|
|
836
|
-
options(options: PropertyLookupOptions): this;
|
|
837
|
-
options(configurator: (builder: PropertyLookupOptionsBuilder) => void): this;
|
|
838
903
|
build(): PropertySearchRequest;
|
|
839
904
|
}
|
|
840
905
|
/**
|
|
841
906
|
* Builder for property search async requests
|
|
842
907
|
*/
|
|
843
|
-
export declare class PropertySearchAsyncRequestBuilder extends
|
|
908
|
+
export declare class PropertySearchAsyncRequestBuilder extends RequestWithSearchCriteriaBuilder<PropertySearchAsyncRequest> {
|
|
844
909
|
static from(request: PropertySearchAsyncRequest): PropertySearchAsyncRequestBuilder;
|
|
845
|
-
searchCriteria(criteria: SearchCriteria): this;
|
|
846
|
-
searchCriteria(configurator: (builder: SearchCriteriaBuilder) => void): this;
|
|
847
|
-
options(options: PropertyLookupOptions): this;
|
|
848
|
-
options(configurator: (builder: PropertyLookupOptionsBuilder) => void): this;
|
|
849
910
|
build(): PropertySearchAsyncRequest;
|
|
850
911
|
}
|
|
851
912
|
/**
|
|
852
913
|
* Builder for property lookup async requests
|
|
853
914
|
*/
|
|
854
|
-
export declare class PropertyLookupAsyncRequestBuilder extends
|
|
915
|
+
export declare class PropertyLookupAsyncRequestBuilder extends RequestWithLookupOptionsBuilder<PropertyLookupAsyncRequest> {
|
|
855
916
|
private requestItems;
|
|
856
917
|
static from(request: PropertyLookupAsyncRequest): PropertyLookupAsyncRequestBuilder;
|
|
857
918
|
items(items: PropertyLookupRequestItem[]): this;
|
|
858
919
|
addItem(item: PropertyLookupRequestItem): this;
|
|
859
920
|
addItemBuilder(builder: PropertyLookupRequestItemBuilder): this;
|
|
860
|
-
options(options: PropertyLookupOptions): this;
|
|
861
|
-
options(configurator: (builder: PropertyLookupOptionsBuilder) => void): this;
|
|
862
921
|
build(): PropertyLookupAsyncRequest;
|
|
863
922
|
}
|
|
864
923
|
/**
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.PropertyPermitRequestBuilder = exports.PropertyLookupAsyncRequestBuilder = exports.PropertySearchAsyncRequestBuilder = exports.PropertySearchRequestBuilder = exports.PropertyCountRequestBuilder = exports.PropertyLookupRequestBuilder = exports.AsyncPropertyLookupOptionsBuilder = exports.PropertyLookupOptionsBuilder = exports.PropertyLookupRequestItemBuilder = exports.PropertySubscriptionBuilder = exports.DeliveryConfigBuilder = exports.SearchCriteriaBuilder = exports.OrSearchCriteriaBuilder = exports.ValuationSearchCriteriaBuilder = exports.TaxSearchCriteriaBuilder = exports.SaleSearchCriteriaBuilder = exports.PropertyOwnerProfileSearchCriteriaBuilder = exports.PermitSearchCriteriaBuilder = exports.OwnerSearchCriteriaBuilder = exports.OpenLienSearchCriteriaBuilder = exports.LotSearchCriteriaBuilder = exports.ListingSearchCriteriaBuilder = exports.LegalSearchCriteriaBuilder = exports.InvoluntaryLienSearchCriteriaBuilder = exports.IntelSearchCriteriaBuilder = exports.IdsSearchCriteriaBuilder = exports.GeneralSearchCriteriaBuilder = exports.ForeclosureSearchCriteriaBuilder = exports.DemographicsSearchCriteriaBuilder = exports.CompAddressSearchCriteriaBuilder = exports.BuildingSearchCriteriaBuilder = exports.AssessmentSearchCriteriaBuilder = exports.AddressSearchCriteriaBuilder = exports.GeoLocationFactory = exports.DateRangeFilterBuilder = exports.NumericRangeFilterBuilder = exports.StringFilterBuilder = void 0;
|
|
21
|
+
exports.PropertyPermitRequestBuilder = exports.PropertyLookupAsyncRequestBuilder = exports.PropertySearchAsyncRequestBuilder = exports.PropertySearchRequestBuilder = exports.PropertyCountRequestBuilder = exports.PropertyLookupRequestBuilder = exports.AsyncPropertyLookupOptionsBuilder = exports.PropertyLookupOptionsBuilder = exports.PropertyLookupRequestItemBuilder = exports.PropertySubscriptionBuilder = exports.DeliveryConfigBuilder = exports.SearchCriteriaBuilder = exports.OrSearchCriteriaBuilder = exports.ValuationSearchCriteriaBuilder = exports.TaxSearchCriteriaBuilder = exports.SaleSearchCriteriaBuilder = exports.PropertyOwnerProfileSearchCriteriaBuilder = exports.PermitSearchCriteriaBuilder = exports.OwnerSearchCriteriaBuilder = exports.OpenLienSearchCriteriaBuilder = exports.LotSearchCriteriaBuilder = exports.ListingSearchCriteriaBuilder = exports.LegalSearchCriteriaBuilder = exports.InvoluntaryLienSearchCriteriaBuilder = exports.IntelSearchCriteriaBuilder = exports.IdsSearchCriteriaBuilder = exports.GeneralSearchCriteriaBuilder = exports.ForeclosureSearchCriteriaBuilder = exports.DemographicsSearchCriteriaBuilder = exports.CompAddressSearchCriteriaBuilder = exports.BuildingSearchCriteriaBuilder = exports.AssessmentSearchCriteriaBuilder = exports.AddressSearchCriteriaBuilder = exports.GeoLocationFactory = exports.DateRangeFilterBuilder = exports.NumericRangeFilterBuilder = exports.StringFilterBuilder = exports.RequestWithSearchCriteriaBuilder = exports.RequestWithLookupOptionsBuilder = void 0;
|
|
22
22
|
const metadata_1 = require("../property-field/metadata");
|
|
23
23
|
const utils_1 = require("../property-field/utils");
|
|
24
24
|
/**
|
|
@@ -164,6 +164,69 @@ class BaseBuilder {
|
|
|
164
164
|
return result;
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Base class for builders that work with RequestWithLookupOptions types.
|
|
169
|
+
* Provides the common `options` method implementation.
|
|
170
|
+
*
|
|
171
|
+
* Builders that work with requests that have PropertyLookupOptions should extend
|
|
172
|
+
* this class instead of BaseBuilder directly.
|
|
173
|
+
*/
|
|
174
|
+
class RequestWithLookupOptionsBuilder extends BaseBuilder {
|
|
175
|
+
options(optionsOrConfigurator) {
|
|
176
|
+
return this.setPropertyWithBuilderClass("options", optionsOrConfigurator, PropertyLookupOptionsBuilder);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Helper method to build options into a request object.
|
|
180
|
+
* This is used by subclasses in their build() methods.
|
|
181
|
+
*
|
|
182
|
+
* @param request - The request object being built
|
|
183
|
+
* @returns The request object with options applied (if any)
|
|
184
|
+
*/
|
|
185
|
+
buildOptionsIntoRequest(request) {
|
|
186
|
+
if (this.builders.options) {
|
|
187
|
+
request.options = this.builders.options.build();
|
|
188
|
+
}
|
|
189
|
+
else if (this.criteria.options) {
|
|
190
|
+
request.options = this.criteria.options;
|
|
191
|
+
}
|
|
192
|
+
return request;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.RequestWithLookupOptionsBuilder = RequestWithLookupOptionsBuilder;
|
|
196
|
+
/**
|
|
197
|
+
* Base class for builders that work with RequestWithSearchCriteria types.
|
|
198
|
+
* Provides the common `searchCriteria` and `options` method implementations.
|
|
199
|
+
*
|
|
200
|
+
* Builders that work with requests that have both searchCriteria and options
|
|
201
|
+
* should extend this class instead of RequestWithLookupOptionsBuilder directly.
|
|
202
|
+
*/
|
|
203
|
+
class RequestWithSearchCriteriaBuilder extends RequestWithLookupOptionsBuilder {
|
|
204
|
+
searchCriteria(criteriaOrConfigurator) {
|
|
205
|
+
if (typeof criteriaOrConfigurator === "function") {
|
|
206
|
+
const builder = new SearchCriteriaBuilder("");
|
|
207
|
+
criteriaOrConfigurator(builder);
|
|
208
|
+
this.criteria.searchCriteria = builder.build();
|
|
209
|
+
this.builders.searchCriteria = undefined;
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
this.criteria.searchCriteria = criteriaOrConfigurator;
|
|
213
|
+
this.builders.searchCriteria = undefined;
|
|
214
|
+
}
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Helper method to validate that searchCriteria is present in build() methods.
|
|
219
|
+
* Throws an error if searchCriteria is missing.
|
|
220
|
+
*
|
|
221
|
+
* @throws Error if searchCriteria is not set
|
|
222
|
+
*/
|
|
223
|
+
validateSearchCriteria() {
|
|
224
|
+
if (!this.criteria.searchCriteria) {
|
|
225
|
+
throw new Error("Search criteria is required");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.RequestWithSearchCriteriaBuilder = RequestWithSearchCriteriaBuilder;
|
|
167
230
|
/**
|
|
168
231
|
* Base builder for string filters
|
|
169
232
|
* @template T - Optional union type of allowed string values. Defaults to `string` for backward compatibility.
|
|
@@ -2209,25 +2272,15 @@ exports.DeliveryConfigBuilder = DeliveryConfigBuilder;
|
|
|
2209
2272
|
/**
|
|
2210
2273
|
* Main builder for property subscription requests
|
|
2211
2274
|
*/
|
|
2212
|
-
class PropertySubscriptionBuilder extends
|
|
2275
|
+
class PropertySubscriptionBuilder extends RequestWithSearchCriteriaBuilder {
|
|
2213
2276
|
static from(request) {
|
|
2214
2277
|
const builder = new PropertySubscriptionBuilder();
|
|
2215
2278
|
builder.searchCriteria(request.searchCriteria);
|
|
2216
2279
|
builder.deliveryConfig(request.deliveryConfig);
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
searchCriteria(criteriaOrConfigurator) {
|
|
2220
|
-
if (typeof criteriaOrConfigurator === "function") {
|
|
2221
|
-
const builder = new SearchCriteriaBuilder("");
|
|
2222
|
-
criteriaOrConfigurator(builder);
|
|
2223
|
-
this.criteria.searchCriteria = builder.build();
|
|
2224
|
-
this.builders.searchCriteria = undefined;
|
|
2225
|
-
}
|
|
2226
|
-
else {
|
|
2227
|
-
this.criteria.searchCriteria = criteriaOrConfigurator;
|
|
2228
|
-
this.builders.searchCriteria = undefined;
|
|
2280
|
+
if (request.options) {
|
|
2281
|
+
builder.options(request.options);
|
|
2229
2282
|
}
|
|
2230
|
-
return
|
|
2283
|
+
return builder;
|
|
2231
2284
|
}
|
|
2232
2285
|
deliveryConfig(configOrConfigurator) {
|
|
2233
2286
|
if (typeof configOrConfigurator === "function") {
|
|
@@ -2243,16 +2296,15 @@ class PropertySubscriptionBuilder extends BaseBuilder {
|
|
|
2243
2296
|
return this;
|
|
2244
2297
|
}
|
|
2245
2298
|
build() {
|
|
2246
|
-
|
|
2247
|
-
throw new Error("Search criteria is required");
|
|
2248
|
-
}
|
|
2299
|
+
this.validateSearchCriteria();
|
|
2249
2300
|
if (!this.criteria.deliveryConfig) {
|
|
2250
2301
|
throw new Error("Delivery configuration is required");
|
|
2251
2302
|
}
|
|
2252
|
-
|
|
2303
|
+
const request = {
|
|
2253
2304
|
searchCriteria: this.criteria.searchCriteria,
|
|
2254
2305
|
deliveryConfig: this.criteria.deliveryConfig,
|
|
2255
2306
|
};
|
|
2307
|
+
return this.buildOptionsIntoRequest(request);
|
|
2256
2308
|
}
|
|
2257
2309
|
}
|
|
2258
2310
|
exports.PropertySubscriptionBuilder = PropertySubscriptionBuilder;
|
|
@@ -2454,7 +2506,7 @@ exports.AsyncPropertyLookupOptionsBuilder = AsyncPropertyLookupOptionsBuilder;
|
|
|
2454
2506
|
/**
|
|
2455
2507
|
* Builder for property lookup requests
|
|
2456
2508
|
*/
|
|
2457
|
-
class PropertyLookupRequestBuilder extends
|
|
2509
|
+
class PropertyLookupRequestBuilder extends RequestWithLookupOptionsBuilder {
|
|
2458
2510
|
constructor() {
|
|
2459
2511
|
super(...arguments);
|
|
2460
2512
|
this.requestItems = [];
|
|
@@ -2479,20 +2531,11 @@ class PropertyLookupRequestBuilder extends BaseBuilder {
|
|
|
2479
2531
|
this.requestItems.push(builder.build());
|
|
2480
2532
|
return this;
|
|
2481
2533
|
}
|
|
2482
|
-
options(optionsOrConfigurator) {
|
|
2483
|
-
return this.setPropertyWithBuilderClass("options", optionsOrConfigurator, PropertyLookupOptionsBuilder);
|
|
2484
|
-
}
|
|
2485
2534
|
build() {
|
|
2486
2535
|
const request = {
|
|
2487
2536
|
requests: this.requestItems,
|
|
2488
2537
|
};
|
|
2489
|
-
|
|
2490
|
-
request.options = this.builders.options.build();
|
|
2491
|
-
}
|
|
2492
|
-
else if (this.criteria.options) {
|
|
2493
|
-
request.options = this.criteria.options;
|
|
2494
|
-
}
|
|
2495
|
-
return request;
|
|
2538
|
+
return this.buildOptionsIntoRequest(request);
|
|
2496
2539
|
}
|
|
2497
2540
|
}
|
|
2498
2541
|
exports.PropertyLookupRequestBuilder = PropertyLookupRequestBuilder;
|
|
@@ -2533,7 +2576,7 @@ exports.PropertyCountRequestBuilder = PropertyCountRequestBuilder;
|
|
|
2533
2576
|
/**
|
|
2534
2577
|
* Builder for property search requests
|
|
2535
2578
|
*/
|
|
2536
|
-
class PropertySearchRequestBuilder extends
|
|
2579
|
+
class PropertySearchRequestBuilder extends RequestWithSearchCriteriaBuilder {
|
|
2537
2580
|
static from(request) {
|
|
2538
2581
|
const builder = new PropertySearchRequestBuilder();
|
|
2539
2582
|
builder.searchCriteria(request.searchCriteria);
|
|
@@ -2542,43 +2585,19 @@ class PropertySearchRequestBuilder extends BaseBuilder {
|
|
|
2542
2585
|
}
|
|
2543
2586
|
return builder;
|
|
2544
2587
|
}
|
|
2545
|
-
searchCriteria(criteriaOrConfigurator) {
|
|
2546
|
-
if (typeof criteriaOrConfigurator === "function") {
|
|
2547
|
-
const builder = new SearchCriteriaBuilder("");
|
|
2548
|
-
criteriaOrConfigurator(builder);
|
|
2549
|
-
this.criteria.searchCriteria = builder.build();
|
|
2550
|
-
this.builders.searchCriteria = undefined;
|
|
2551
|
-
}
|
|
2552
|
-
else {
|
|
2553
|
-
this.criteria.searchCriteria = criteriaOrConfigurator;
|
|
2554
|
-
this.builders.searchCriteria = undefined;
|
|
2555
|
-
}
|
|
2556
|
-
return this;
|
|
2557
|
-
}
|
|
2558
|
-
options(optionsOrConfigurator) {
|
|
2559
|
-
return this.setPropertyWithBuilderClass("options", optionsOrConfigurator, PropertyLookupOptionsBuilder);
|
|
2560
|
-
}
|
|
2561
2588
|
build() {
|
|
2562
|
-
|
|
2563
|
-
throw new Error("Search criteria is required");
|
|
2564
|
-
}
|
|
2589
|
+
this.validateSearchCriteria();
|
|
2565
2590
|
const request = {
|
|
2566
2591
|
searchCriteria: this.criteria.searchCriteria,
|
|
2567
2592
|
};
|
|
2568
|
-
|
|
2569
|
-
request.options = this.builders.options.build();
|
|
2570
|
-
}
|
|
2571
|
-
else if (this.criteria.options) {
|
|
2572
|
-
request.options = this.criteria.options;
|
|
2573
|
-
}
|
|
2574
|
-
return request;
|
|
2593
|
+
return this.buildOptionsIntoRequest(request);
|
|
2575
2594
|
}
|
|
2576
2595
|
}
|
|
2577
2596
|
exports.PropertySearchRequestBuilder = PropertySearchRequestBuilder;
|
|
2578
2597
|
/**
|
|
2579
2598
|
* Builder for property search async requests
|
|
2580
2599
|
*/
|
|
2581
|
-
class PropertySearchAsyncRequestBuilder extends
|
|
2600
|
+
class PropertySearchAsyncRequestBuilder extends RequestWithSearchCriteriaBuilder {
|
|
2582
2601
|
static from(request) {
|
|
2583
2602
|
const builder = new PropertySearchAsyncRequestBuilder();
|
|
2584
2603
|
builder.searchCriteria(request.searchCriteria);
|
|
@@ -2587,43 +2606,19 @@ class PropertySearchAsyncRequestBuilder extends BaseBuilder {
|
|
|
2587
2606
|
}
|
|
2588
2607
|
return builder;
|
|
2589
2608
|
}
|
|
2590
|
-
searchCriteria(criteriaOrConfigurator) {
|
|
2591
|
-
if (typeof criteriaOrConfigurator === "function") {
|
|
2592
|
-
const builder = new SearchCriteriaBuilder("");
|
|
2593
|
-
criteriaOrConfigurator(builder);
|
|
2594
|
-
this.criteria.searchCriteria = builder.build();
|
|
2595
|
-
this.builders.searchCriteria = undefined;
|
|
2596
|
-
}
|
|
2597
|
-
else {
|
|
2598
|
-
this.criteria.searchCriteria = criteriaOrConfigurator;
|
|
2599
|
-
this.builders.searchCriteria = undefined;
|
|
2600
|
-
}
|
|
2601
|
-
return this;
|
|
2602
|
-
}
|
|
2603
|
-
options(optionsOrConfigurator) {
|
|
2604
|
-
return this.setPropertyWithBuilderClass("options", optionsOrConfigurator, PropertyLookupOptionsBuilder);
|
|
2605
|
-
}
|
|
2606
2609
|
build() {
|
|
2607
|
-
|
|
2608
|
-
throw new Error("Search criteria is required");
|
|
2609
|
-
}
|
|
2610
|
+
this.validateSearchCriteria();
|
|
2610
2611
|
const request = {
|
|
2611
2612
|
searchCriteria: this.criteria.searchCriteria,
|
|
2612
2613
|
};
|
|
2613
|
-
|
|
2614
|
-
request.options = this.builders.options.build();
|
|
2615
|
-
}
|
|
2616
|
-
else if (this.criteria.options) {
|
|
2617
|
-
request.options = this.criteria.options;
|
|
2618
|
-
}
|
|
2619
|
-
return request;
|
|
2614
|
+
return this.buildOptionsIntoRequest(request);
|
|
2620
2615
|
}
|
|
2621
2616
|
}
|
|
2622
2617
|
exports.PropertySearchAsyncRequestBuilder = PropertySearchAsyncRequestBuilder;
|
|
2623
2618
|
/**
|
|
2624
2619
|
* Builder for property lookup async requests
|
|
2625
2620
|
*/
|
|
2626
|
-
class PropertyLookupAsyncRequestBuilder extends
|
|
2621
|
+
class PropertyLookupAsyncRequestBuilder extends RequestWithLookupOptionsBuilder {
|
|
2627
2622
|
constructor() {
|
|
2628
2623
|
super(...arguments);
|
|
2629
2624
|
this.requestItems = [];
|
|
@@ -2648,20 +2643,11 @@ class PropertyLookupAsyncRequestBuilder extends BaseBuilder {
|
|
|
2648
2643
|
this.requestItems.push(builder.build());
|
|
2649
2644
|
return this;
|
|
2650
2645
|
}
|
|
2651
|
-
options(optionsOrConfigurator) {
|
|
2652
|
-
return this.setPropertyWithBuilderClass("options", optionsOrConfigurator, PropertyLookupOptionsBuilder);
|
|
2653
|
-
}
|
|
2654
2646
|
build() {
|
|
2655
2647
|
const request = {
|
|
2656
2648
|
requests: this.requestItems,
|
|
2657
2649
|
};
|
|
2658
|
-
|
|
2659
|
-
request.options = this.builders.options.build();
|
|
2660
|
-
}
|
|
2661
|
-
else if (this.criteria.options) {
|
|
2662
|
-
request.options = this.criteria.options;
|
|
2663
|
-
}
|
|
2664
|
-
return request;
|
|
2650
|
+
return this.buildOptionsIntoRequest(request);
|
|
2665
2651
|
}
|
|
2666
2652
|
}
|
|
2667
2653
|
exports.PropertyLookupAsyncRequestBuilder = PropertyLookupAsyncRequestBuilder;
|
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, 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 } 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.).
|
|
@@ -129,6 +129,41 @@ export interface BatchDataClientOptions {
|
|
|
129
129
|
* Allows specifying webhook URLs per endpoint type, with fallback to defaults
|
|
130
130
|
*/
|
|
131
131
|
webhooks?: AsyncWebhookConfiguration;
|
|
132
|
+
/**
|
|
133
|
+
* Optional default PropertyLookupOptions to apply to all requests
|
|
134
|
+
* These defaults are merged with request-specific options, with request options taking precedence
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* const client = new BatchDataClient({
|
|
139
|
+
* apiKey: "...",
|
|
140
|
+
* defaultOptions: {
|
|
141
|
+
* take: 100, // Default to 100 properties if not specified
|
|
142
|
+
* }
|
|
143
|
+
* });
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
defaultOptions?: PropertyLookupOptions;
|
|
147
|
+
/**
|
|
148
|
+
* Optional maximum `take` value to enforce on all requests
|
|
149
|
+
* If a request specifies a `take` value greater than this, it will be capped to this maximum
|
|
150
|
+
* This is useful for enforcing API limits or preventing accidental large requests
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const client = new BatchDataClient({
|
|
155
|
+
* apiKey: "...",
|
|
156
|
+
* maxTake: 100, // Cap all requests to max 100 properties
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* // Even if request specifies take: 500, it will be capped to 100
|
|
160
|
+
* await client.searchProperties({
|
|
161
|
+
* searchCriteria: { query: "AZ" },
|
|
162
|
+
* options: { take: 500 } // Will be capped to 100
|
|
163
|
+
* });
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
maxTake?: number;
|
|
132
167
|
}
|
|
133
168
|
/**
|
|
134
169
|
* BatchData API Client
|
|
@@ -143,6 +178,8 @@ export declare class BatchDataClient implements IBatchDataClient {
|
|
|
143
178
|
protected readonly axiosInstance: AxiosInstance;
|
|
144
179
|
protected readonly logger: ILogger;
|
|
145
180
|
private readonly webhooks?;
|
|
181
|
+
private readonly defaultOptions?;
|
|
182
|
+
private readonly maxTake?;
|
|
146
183
|
constructor(options: BatchDataClientOptions);
|
|
147
184
|
/**
|
|
148
185
|
* Obfuscate sensitive headers (like Authorization) for logging
|
|
@@ -169,6 +206,30 @@ export declare class BatchDataClient implements IBatchDataClient {
|
|
|
169
206
|
* @returns The request with webhook URLs applied (if needed)
|
|
170
207
|
*/
|
|
171
208
|
private applyDefaultWebhookUrls;
|
|
209
|
+
/**
|
|
210
|
+
* Get the maximum take value for a request, applying maxTake limit if configured.
|
|
211
|
+
*
|
|
212
|
+
* @param originalRequest The original request
|
|
213
|
+
* @returns The take value to use (capped if necessary)
|
|
214
|
+
*/
|
|
215
|
+
private getMaxPropertyTake;
|
|
216
|
+
/**
|
|
217
|
+
* Apply defaults and limits to a request with search criteria.
|
|
218
|
+
* Uses the shared RequestWithSearchCriteria interface.
|
|
219
|
+
* Currently caps the take value based on maxTake config.
|
|
220
|
+
*
|
|
221
|
+
* @param request The request with search criteria to apply defaults to
|
|
222
|
+
* @returns A new request with defaults applied
|
|
223
|
+
*/
|
|
224
|
+
private applySearchRequestDefaultsAndLimits;
|
|
225
|
+
/**
|
|
226
|
+
* Apply default options to a request that supports PropertyLookupOptions.
|
|
227
|
+
* Defaults are merged with request-specific options, with request options taking precedence.
|
|
228
|
+
*
|
|
229
|
+
* @param request The request to apply defaults to
|
|
230
|
+
* @returns The request with defaults applied (if defaults are configured)
|
|
231
|
+
*/
|
|
232
|
+
private applyDefaultOptions;
|
|
172
233
|
/**
|
|
173
234
|
* Apply default webhook URLs to a property subscription request if they're not already set.
|
|
174
235
|
* This helper ensures that if webhook URLs are configured in the client,
|
package/dist/client/client.js
CHANGED
|
@@ -24,6 +24,8 @@ 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.defaultOptions = options.defaultOptions;
|
|
28
|
+
this.maxTake = options.maxTake;
|
|
27
29
|
this.axiosInstance = axios_1.default.create({
|
|
28
30
|
timeout: options.timeout || 30000,
|
|
29
31
|
headers: {
|
|
@@ -211,6 +213,80 @@ class BatchDataClient {
|
|
|
211
213
|
},
|
|
212
214
|
};
|
|
213
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Get the maximum take value for a request, applying maxTake limit if configured.
|
|
218
|
+
*
|
|
219
|
+
* @param originalRequest The original request
|
|
220
|
+
* @returns The take value to use (capped if necessary)
|
|
221
|
+
*/
|
|
222
|
+
getMaxPropertyTake(originalRequest) {
|
|
223
|
+
if (this.maxTake === undefined) {
|
|
224
|
+
return originalRequest.options?.take;
|
|
225
|
+
}
|
|
226
|
+
const { take: originalTake } = originalRequest.options ?? {};
|
|
227
|
+
if (!originalTake)
|
|
228
|
+
return this.maxTake;
|
|
229
|
+
if (originalTake > this.maxTake) {
|
|
230
|
+
this.logger.warn(`Property search take value capped from ${originalTake} to ${this.maxTake} (maxTake limit)`);
|
|
231
|
+
return this.maxTake;
|
|
232
|
+
}
|
|
233
|
+
return originalTake;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Apply defaults and limits to a request with search criteria.
|
|
237
|
+
* Uses the shared RequestWithSearchCriteria interface.
|
|
238
|
+
* Currently caps the take value based on maxTake config.
|
|
239
|
+
*
|
|
240
|
+
* @param request The request with search criteria to apply defaults to
|
|
241
|
+
* @returns A new request with defaults applied
|
|
242
|
+
*/
|
|
243
|
+
applySearchRequestDefaultsAndLimits(request) {
|
|
244
|
+
// First merge defaults if configured
|
|
245
|
+
let requestWithDefaults = request;
|
|
246
|
+
if (this.defaultOptions) {
|
|
247
|
+
requestWithDefaults = this.applyDefaultOptions(request);
|
|
248
|
+
}
|
|
249
|
+
// Then apply maxTake limit
|
|
250
|
+
const maxTake = this.getMaxPropertyTake(requestWithDefaults);
|
|
251
|
+
if (maxTake !== undefined) {
|
|
252
|
+
return {
|
|
253
|
+
...requestWithDefaults,
|
|
254
|
+
options: {
|
|
255
|
+
...requestWithDefaults.options,
|
|
256
|
+
take: maxTake,
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return requestWithDefaults;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Apply default options to a request that supports PropertyLookupOptions.
|
|
264
|
+
* Defaults are merged with request-specific options, with request options taking precedence.
|
|
265
|
+
*
|
|
266
|
+
* @param request The request to apply defaults to
|
|
267
|
+
* @returns The request with defaults applied (if defaults are configured)
|
|
268
|
+
*/
|
|
269
|
+
applyDefaultOptions(request) {
|
|
270
|
+
// If no defaults are configured, return original request
|
|
271
|
+
if (!this.defaultOptions) {
|
|
272
|
+
return request;
|
|
273
|
+
}
|
|
274
|
+
// Merge defaults with request options (request options take precedence)
|
|
275
|
+
const mergedOptions = {
|
|
276
|
+
...this.defaultOptions,
|
|
277
|
+
...request.options,
|
|
278
|
+
};
|
|
279
|
+
// If no options were actually merged (request had no options and defaults don't add anything),
|
|
280
|
+
// return original request
|
|
281
|
+
if (!request.options && Object.keys(mergedOptions).length === 0) {
|
|
282
|
+
return request;
|
|
283
|
+
}
|
|
284
|
+
// Return a new request object with merged options
|
|
285
|
+
return {
|
|
286
|
+
...request,
|
|
287
|
+
options: mergedOptions,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
214
290
|
/**
|
|
215
291
|
* Apply default webhook URLs to a property subscription request if they're not already set.
|
|
216
292
|
* This helper ensures that if webhook URLs are configured in the client,
|
|
@@ -374,7 +450,10 @@ class BatchDataClient {
|
|
|
374
450
|
async createPropertySubscription(request) {
|
|
375
451
|
const url = `${this.v2BaseUrl}/property-subscription`;
|
|
376
452
|
// Apply default webhook URLs if configured
|
|
377
|
-
|
|
453
|
+
let requestWithDefaults = this.applyPropertySubscriptionWebhooks(request);
|
|
454
|
+
// Apply defaults and limits (including maxTake)
|
|
455
|
+
requestWithDefaults =
|
|
456
|
+
this.applySearchRequestDefaultsAndLimits(requestWithDefaults);
|
|
378
457
|
this.logger.debug(`Creating property subscription: POST ${url}`, {
|
|
379
458
|
query: requestWithDefaults.searchCriteria.query,
|
|
380
459
|
});
|
|
@@ -403,12 +482,14 @@ class BatchDataClient {
|
|
|
403
482
|
*/
|
|
404
483
|
async searchProperties(request) {
|
|
405
484
|
const url = `${this.v1BaseUrl}/property/search`;
|
|
485
|
+
// Apply defaults and limits (including maxTake)
|
|
486
|
+
const requestWithDefaults = this.applySearchRequestDefaultsAndLimits(request);
|
|
406
487
|
this.logger.debug(`Searching properties: POST ${url}`, {
|
|
407
|
-
query:
|
|
408
|
-
take:
|
|
409
|
-
skip:
|
|
488
|
+
query: requestWithDefaults.searchCriteria.query,
|
|
489
|
+
take: requestWithDefaults.options?.take,
|
|
490
|
+
skip: requestWithDefaults.options?.skip,
|
|
410
491
|
});
|
|
411
|
-
const { data, status } = await this.handleApiCall(() => this.axiosInstance.post(url,
|
|
492
|
+
const { data, status } = await this.handleApiCall(() => this.axiosInstance.post(url, requestWithDefaults), "Failed to search properties", url);
|
|
412
493
|
this.logger.debug(`Property search completed`, {
|
|
413
494
|
status,
|
|
414
495
|
hasData: !!data,
|
|
@@ -530,10 +611,12 @@ class BatchDataClient {
|
|
|
530
611
|
*/
|
|
531
612
|
async lookupProperty(request) {
|
|
532
613
|
const url = `${this.v1BaseUrl}/property/lookup/all-attributes`;
|
|
614
|
+
// Apply default options if configured
|
|
615
|
+
const requestWithDefaults = this.applyDefaultOptions(request);
|
|
533
616
|
this.logger.debug(`Looking up property: POST ${url}`, {
|
|
534
|
-
requestCount:
|
|
617
|
+
requestCount: requestWithDefaults.requests.length,
|
|
535
618
|
});
|
|
536
|
-
const { data, status } = await this.handleApiCall(() => this.axiosInstance.post(url,
|
|
619
|
+
const { data, status } = await this.handleApiCall(() => this.axiosInstance.post(url, requestWithDefaults), "Failed to lookup property", url);
|
|
537
620
|
this.logger.debug(`Property lookup completed`, {
|
|
538
621
|
status,
|
|
539
622
|
propertyCount: data.results?.properties?.length,
|
|
@@ -550,7 +633,9 @@ class BatchDataClient {
|
|
|
550
633
|
async lookupPropertyAsync(request) {
|
|
551
634
|
const url = `${this.v1BaseUrl}/property/lookup/async`;
|
|
552
635
|
// Apply default webhook URLs if configured
|
|
553
|
-
|
|
636
|
+
let requestWithDefaults = this.applyDefaultWebhookUrls(request, "propertyLookup");
|
|
637
|
+
// Apply default options if configured
|
|
638
|
+
requestWithDefaults = this.applyDefaultOptions(requestWithDefaults);
|
|
554
639
|
this.logger.debug(`Looking up property async: POST ${url}`, {
|
|
555
640
|
requestCount: requestWithDefaults.requests.length,
|
|
556
641
|
});
|
|
@@ -571,7 +656,10 @@ class BatchDataClient {
|
|
|
571
656
|
async searchPropertiesAsync(request) {
|
|
572
657
|
const url = `${this.v1BaseUrl}/property/search/async`;
|
|
573
658
|
// Apply default webhook URLs if configured
|
|
574
|
-
|
|
659
|
+
let requestWithDefaults = this.applyDefaultWebhookUrls(request, "propertySearch");
|
|
660
|
+
// Apply defaults and limits (including maxTake)
|
|
661
|
+
requestWithDefaults =
|
|
662
|
+
this.applySearchRequestDefaultsAndLimits(requestWithDefaults);
|
|
575
663
|
this.logger.debug(`Searching properties async: POST ${url}`, {
|
|
576
664
|
query: requestWithDefaults.searchCriteria.query,
|
|
577
665
|
});
|
package/dist/core/types.d.ts
CHANGED
|
@@ -478,8 +478,7 @@ export interface DeliveryConfig {
|
|
|
478
478
|
/**
|
|
479
479
|
* Property subscription request payload
|
|
480
480
|
*/
|
|
481
|
-
export interface PropertySubscriptionRequest {
|
|
482
|
-
searchCriteria: SearchCriteria;
|
|
481
|
+
export interface PropertySubscriptionRequest extends RequestWithSearchCriteria {
|
|
483
482
|
deliveryConfig: DeliveryConfig;
|
|
484
483
|
}
|
|
485
484
|
/**
|
|
@@ -1712,6 +1711,58 @@ export interface PropertyLookupRequestItem {
|
|
|
1712
1711
|
countyFipsCode?: string;
|
|
1713
1712
|
requestId?: string;
|
|
1714
1713
|
}
|
|
1714
|
+
/**
|
|
1715
|
+
* Base interface for requests that support PropertyLookupOptions
|
|
1716
|
+
* This allows for type-safe application of defaults and limits across request types
|
|
1717
|
+
*
|
|
1718
|
+
* @example
|
|
1719
|
+
* ```typescript
|
|
1720
|
+
* // Apply defaults to any request with lookup options
|
|
1721
|
+
* function applyDefaults<T extends RequestWithLookupOptions>(
|
|
1722
|
+
* request: T,
|
|
1723
|
+
* defaults: PropertyLookupOptions
|
|
1724
|
+
* ): T {
|
|
1725
|
+
* return {
|
|
1726
|
+
* ...request,
|
|
1727
|
+
* options: { ...defaults, ...request.options },
|
|
1728
|
+
* };
|
|
1729
|
+
* }
|
|
1730
|
+
* ```
|
|
1731
|
+
*/
|
|
1732
|
+
export interface RequestWithLookupOptions {
|
|
1733
|
+
options?: PropertyLookupOptions;
|
|
1734
|
+
}
|
|
1735
|
+
/**
|
|
1736
|
+
* Base interface for requests that have both searchCriteria and PropertyLookupOptions
|
|
1737
|
+
* Most search-based requests extend this interface
|
|
1738
|
+
*
|
|
1739
|
+
* @example
|
|
1740
|
+
* ```typescript
|
|
1741
|
+
* // Apply defaults to any request with search criteria and options
|
|
1742
|
+
* function applySearchDefaults<T extends RequestWithSearchCriteria>(
|
|
1743
|
+
* request: T,
|
|
1744
|
+
* defaults: PropertyLookupOptions
|
|
1745
|
+
* ): T {
|
|
1746
|
+
* return {
|
|
1747
|
+
* ...request,
|
|
1748
|
+
* options: { ...defaults, ...request.options },
|
|
1749
|
+
* };
|
|
1750
|
+
* }
|
|
1751
|
+
* ```
|
|
1752
|
+
*/
|
|
1753
|
+
export interface RequestWithSearchCriteria extends RequestWithLookupOptions {
|
|
1754
|
+
searchCriteria: SearchCriteria;
|
|
1755
|
+
}
|
|
1756
|
+
/**
|
|
1757
|
+
* Type helper to extract request types that support PropertyLookupOptions
|
|
1758
|
+
* Useful for writing generic functions that work with any request type
|
|
1759
|
+
*/
|
|
1760
|
+
export type RequestWithLookupOptionsType = PropertySearchRequest | PropertySearchAsyncRequest | PropertyLookupRequest | PropertyLookupAsyncRequest | PropertySubscriptionRequest;
|
|
1761
|
+
/**
|
|
1762
|
+
* Type helper to extract request types that have both searchCriteria and options
|
|
1763
|
+
* Useful for writing generic functions that work with search-based requests
|
|
1764
|
+
*/
|
|
1765
|
+
export type RequestWithSearchCriteriaType = PropertySearchRequest | PropertySearchAsyncRequest | PropertySubscriptionRequest;
|
|
1715
1766
|
/**
|
|
1716
1767
|
* Property lookup options (shared with property search)
|
|
1717
1768
|
*/
|
|
@@ -1764,10 +1815,7 @@ export interface PropertyLookupOptions {
|
|
|
1764
1815
|
/**
|
|
1765
1816
|
* Property search request (synchronous)
|
|
1766
1817
|
*/
|
|
1767
|
-
export
|
|
1768
|
-
searchCriteria: SearchCriteria;
|
|
1769
|
-
options?: PropertyLookupOptions;
|
|
1770
|
-
}
|
|
1818
|
+
export type PropertySearchRequest = RequestWithSearchCriteria;
|
|
1771
1819
|
/**
|
|
1772
1820
|
* Property count request
|
|
1773
1821
|
*
|
|
@@ -1787,9 +1835,8 @@ export interface PropertyCountRequest {
|
|
|
1787
1835
|
/**
|
|
1788
1836
|
* Property lookup request
|
|
1789
1837
|
*/
|
|
1790
|
-
export interface PropertyLookupRequest {
|
|
1838
|
+
export interface PropertyLookupRequest extends RequestWithLookupOptions {
|
|
1791
1839
|
requests: PropertyLookupRequestItem[];
|
|
1792
|
-
options?: PropertyLookupOptions;
|
|
1793
1840
|
}
|
|
1794
1841
|
/**
|
|
1795
1842
|
* Property lookup API response (same structure as PropertySearchResponse)
|
|
@@ -1804,9 +1851,8 @@ export interface PropertyLookupResponse {
|
|
|
1804
1851
|
/**
|
|
1805
1852
|
* Property lookup async request
|
|
1806
1853
|
*/
|
|
1807
|
-
export interface PropertyLookupAsyncRequest {
|
|
1854
|
+
export interface PropertyLookupAsyncRequest extends RequestWithLookupOptions {
|
|
1808
1855
|
requests: PropertyLookupRequestItem[];
|
|
1809
|
-
options?: PropertyLookupOptions;
|
|
1810
1856
|
}
|
|
1811
1857
|
/**
|
|
1812
1858
|
* Property lookup async API response
|
|
@@ -1823,10 +1869,7 @@ export type PropertyLookupAsyncWebhookPayload = PropertyLookupResponse;
|
|
|
1823
1869
|
/**
|
|
1824
1870
|
* Property search async request
|
|
1825
1871
|
*/
|
|
1826
|
-
export
|
|
1827
|
-
searchCriteria: SearchCriteria;
|
|
1828
|
-
options?: PropertyLookupOptions;
|
|
1829
|
-
}
|
|
1872
|
+
export type PropertySearchAsyncRequest = RequestWithSearchCriteria;
|
|
1830
1873
|
/**
|
|
1831
1874
|
* Property search async API response
|
|
1832
1875
|
* Async endpoints return only a status object. Full results are delivered to the webhook URL.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@land-catalyst/batch-data-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "TypeScript SDK for BatchData.io Property API - Types, Builders, and Utilities",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsc",
|
|
14
14
|
"prepublishOnly": "npm run build",
|
|
15
|
-
"test": "jest",
|
|
15
|
+
"test": "jest --testPathIgnorePatterns=integration",
|
|
16
16
|
"test:integration": "jest --testMatch=\"**/*integration*.test.ts\"",
|
|
17
17
|
"lint": "eslint src",
|
|
18
18
|
"lint:fix": "eslint src --fix",
|